diff --git a/.github/workflows/notify.yaml b/.github/workflows/notify.yaml index e41df19..482ae60 100644 --- a/.github/workflows/notify.yaml +++ b/.github/workflows/notify.yaml @@ -1,16 +1,11 @@ +name: Notify + on: release: types: [published] jobs: notify: - runs-on: ubuntu-latest - - steps: - - name: Publish repository dispatch - uses: ibm-garage-cloud/action-repository-dispatch@main - with: - notifyRepo: ibm-garage-cloud/ibm-garage-iteration-zero - eventType: released - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} + uses: cloud-native-toolkit/action-workflows/.github/workflows/notify.yaml@v1 + secrets: + TOKEN: ${{ secrets.TOKEN }} diff --git a/.github/workflows/publish-assets.yaml b/.github/workflows/publish-assets.yaml deleted file mode 100644 index b704534..0000000 --- a/.github/workflows/publish-assets.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish assets - -on: - release: - types: - - published - -jobs: - publish-assets: - runs-on: ubuntu-latest - - env: - DIST_DIR: ./dist - PUBLISH_BRANCH: gh-pages - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ github.event.release.tag_name }} - - - name: Build catalog - uses: ibm-garage-cloud/action-module-catalog@main - with: - tagName: ${{ github.event.release.tag_name }} - distDir: ${{ env.DIST_DIR }} - publishBranch: ${{ env.PUBLISH_BRANCH }} - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ${{ env.DIST_DIR }} - publish_branch: ${{ env.PUBLISH_BRANCH }} \ No newline at end of file diff --git a/.github/workflows/publish-metadata.yaml b/.github/workflows/publish-metadata.yaml new file mode 100644 index 0000000..f2b1d9c --- /dev/null +++ b/.github/workflows/publish-metadata.yaml @@ -0,0 +1,12 @@ +name: Publish metadata + +on: + release: + types: + - published + +jobs: + publish-assets: + uses: cloud-native-toolkit/action-workflows/.github/workflows/publish-metadata.yaml@v1 + secrets: + TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/verify-pr.yaml b/.github/workflows/verify-pr.yaml new file mode 100644 index 0000000..d8d1949 --- /dev/null +++ b/.github/workflows/verify-pr.yaml @@ -0,0 +1,18 @@ +name: Verify PR + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch +on: + pull_request: + branches: [ main ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + verify: + if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }} + uses: ./.github/workflows/verify-workflow.yaml + secrets: + IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} + + verifyMetadata: + uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-module-metadata.yaml@v1 diff --git a/.github/workflows/verify-workflow.yaml b/.github/workflows/verify-workflow.yaml new file mode 100644 index 0000000..836da1e --- /dev/null +++ b/.github/workflows/verify-workflow.yaml @@ -0,0 +1,47 @@ +name: Verify + +# Controls when the action will run. +on: + workflow_call: + secrets: + IBMCLOUD_API_KEY: + required: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + verify: + if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }} + runs-on: ubuntu-latest + container: quay.io/ibmgaragecloud/cli-tools:v0.15 + + strategy: + matrix: + testcase: + - ocp4_latest + fail-fast: false + + env: + HOME: /home/devops + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Verify deploy on ${{ matrix.testcase }} + uses: cloud-native-toolkit/action-module-verify-deploy@main + with: + clusterId: ${{ matrix.testcase }} + validateDeployScript: .github/scripts/validate-deploy.sh + env: + TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} + IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} + + - name: Verify destroy on ${{ matrix.testcase }} + uses: cloud-native-toolkit/action-module-verify-destroy@main + if: ${{ always() }} + with: + clusterId: ${{ matrix.testcase }} + env: + TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} + IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 7cafb6e..0ceaad9 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -1,65 +1,24 @@ -name: Verify and release module +name: Verify # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the main branch on: push: branches: [ main ] - pull_request: - branches: [ main ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: verify: if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }} - runs-on: ubuntu-latest - container: quay.io/ibmgaragecloud/cli-tools:v0.10.0-lite - - strategy: - matrix: - platform: [ocp4_latest] - # max-parallel: 1 - fail-fast: false - - env: - HOME: /home/devops + uses: ./.github/workflows/verify-workflow.yaml + secrets: + IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Verify deploy on ${{ matrix.platform }} - uses: ibm-garage-cloud/action-module-verify-deploy@main - with: - clusterId: ${{ matrix.platform }} - validateDeployScript: .github/scripts/validate-deploy.sh - env: - TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} - IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} - - - name: Verify destroy on ${{ matrix.platform }} - uses: ibm-garage-cloud/action-module-verify-destroy@main - if: ${{ always() }} - with: - clusterId: ${{ matrix.platform }} - env: - TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} - IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }} + verifyMetadata: + uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-module-metadata.yaml@v1 release: - # if: ${{ github.event_name == 'push' }} - needs: verify - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Drafts your next Release notes as Pull Requests are merged into "main" - - uses: release-drafter/release-drafter@v5 - with: - # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml - config-name: release-drafter.yaml - publish: true - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} + needs: [verify, verifyMetadata] + uses: cloud-native-toolkit/action-workflows/.github/workflows/release-module.yaml@v1 + secrets: + TOKEN: ${{ secrets.TOKEN }} diff --git a/README.md b/README.md index e3f0b5c..ae6ee33 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ module "dev_infrastructure_mongodb" { authorize-kms = var.authorize-kms == "true" } ``` - +## \ No newline at end of file diff --git a/main.tf b/main.tf index e1f2ca3..317666b 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,5 @@ provider "ibm" { - version = ">= 1.17.0" + version = ">= 1.25.0" region = local.key-protect-region } diff --git a/module.yaml b/module.yaml index 7d898dd..753a3f3 100644 --- a/module.yaml +++ b/module.yaml @@ -11,3 +11,11 @@ versions: - kubernetes - ocp3 - ocp4 + providers: + - name: ibm + source: "ibm-cloud/ibm" + dependencies: [] + variables: [] + + + diff --git a/test/stages/provider.tf b/test/stages/provider.tf new file mode 100644 index 0000000..6de479b --- /dev/null +++ b/test/stages/provider.tf @@ -0,0 +1,4 @@ +provider "ibm" { + region = var.region + ibmcloud_api_key = var.ibmcloud_api_key +} \ No newline at end of file diff --git a/test/stages/stage0.tf b/test/stages/stage0.tf index ca88e62..636eaa6 100644 --- a/test/stages/stage0.tf +++ b/test/stages/stage0.tf @@ -1,2 +1,23 @@ terraform { + required_version = ">= 0.15.0" + + required_providers { + ibm = { + source = "ibm-cloud/ibm" + version = ">= 1.25.0" + } + } } + +module setup_clis { + source = "github.com/cloud-native-toolkit/terraform-util-clis.git" + + bin_dir = "${path.cwd}/test_bin_dir" + clis = ["jq", "ibmcloud-is"] +} + +resource local_file bin_dir { + filename = "${path.cwd}/.bin_dir" + + content = module.setup_clis.bin_dir +} \ No newline at end of file diff --git a/version.tf b/version.tf new file mode 100644 index 0000000..50342df --- /dev/null +++ b/version.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 0.13.0" + + required_providers { + ibm = { + source = "ibm-cloud/ibm" + version = ">= 1.25.0" + } + } +} \ No newline at end of file