Skip to content

Upgrade Provider Repositories #166

Upgrade Provider Repositories

Upgrade Provider Repositories #166

name: "Upgrade Provider Repositories"
on:
workflow_dispatch: {}
workflow_call: {}
jobs:
build-provider-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- id: set-matrix
run: |
provider=$(jq -rcM "{ provider: keys }" provider.json)
echo "matrix=$provider" >> $GITHUB_OUTPUT
upgrade-provider:
needs: build-provider-matrix
name: "Upgrade"
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.build-provider-matrix.outputs.matrix)}}
max-parallel: 5
steps:
- name: Checkout this repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
path: main
- name: Checkout cdktf-provider-${{ matrix.provider }} Repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
repository: cdktf/cdktf-provider-${{ matrix.provider }}
token: ${{ secrets.GH_COMMENT_TOKEN }}
path: provider
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
name: Create projen run commands file
with:
script: |
const {resolve} = require('path')
const scriptPath = resolve("./main/.github/lib/create-projen-files")
const script = require(scriptPath)
script({
providerName: "${{matrix.provider}}"
})
- name: Upgrade provider project
run: |
unset CI
git config user.name github-team-tf-cdk
git config user.email github-team-tf-cdk@hashicorp.com
git checkout -b foo-bar-${{ github.run_number }}
yarn add --dev @cdktf/provider-project@latest projen
npx projen
yarn install --check-files
yarn build-provider
npx projen
working-directory: ./provider
env:
NODE_OPTIONS: "--max-old-space-size=7168"
- name: Check for changes
id: git_diff
run: |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT
working-directory: ./provider
- if: steps.git_diff.outputs.has_changes
name: Detect breaking version changes
id: diff_changes
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
const {resolve} = require('path')
const scriptPath = resolve("./main/.github/lib/collect-changes")
const script = require(scriptPath)
await script({core, exec})
- if: steps.git_diff.outputs.has_changes
name: Commit (${{steps.diff_changes.outputs.has_breaking_changes && 'breaking' || 'unbreaking'}}) changes and push changes (if changed)
run: |
git checkout -b upgrade-provider-project-${{ github.run_number }}-${{ github.run_attempt }}
git add .
git commit -m "${{ steps.diff_changes.outputs.commit_message }}"
git push --set-upstream origin upgrade-provider-project-${{ github.run_number }}-${{ github.run_attempt }}
working-directory: ./provider
- if: steps.git_diff.outputs.has_changes
name: "Create PR"
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
github-token: ${{ secrets.GH_COMMENT_TOKEN }}
retries: 5
retry-exempt-status-codes: 400,401,404
script: |
const {resolve} = require('path')
const scriptPath = resolve("./main/.github/lib/create-pr")
const script = require(scriptPath)
await script({
github,
branchName: "upgrade-provider-project-${{ github.run_number }}-${{ github.run_attempt }}",
prTitle: "${{ steps.diff_changes.outputs.commit_message }}",
providerName: "${{matrix.provider}}"
})
- name: Send failures to Slack
if: ${{ failure() && !cancelled() }}
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
payload: |
{
"provider_name": "${{ matrix.provider }}",
"run_url": "https://github.com/cdktf/cdktf-repository-manager/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.FAILURE_SLACK_WEBHOOK_URL }}