Skip to content

upgrade-terraform

upgrade-terraform #79

# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
name: upgrade-terraform
on:
schedule:
- cron: 26 0 * * 4
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
upgrade:
name: Upgrade Terraform
runs-on: ubuntu-latest
permissions:
contents: read
env:
CI: "true"
CHECKPOINT_DISABLE: "1"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: 20.9.0
- name: Install
run: yarn install
- name: Get current Terraform version
id: current_version
run: |-
OLD_VERSION=$(sed -nE 's/default: "(1..*)",/\1/p' .projenrc.ts | xargs)
OLD_VERSION_MINOR=$(cut -d "." -f 2 <<< "$OLD_VERSION")
echo "value=$OLD_VERSION" >> $GITHUB_OUTPUT
echo "minor=$OLD_VERSION_MINOR" >> $GITHUB_OUTPUT
- name: Get latest Terraform version
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |-
const script = require('./scripts/check-terraform-version.js')
await script({github, context, core})
- name: Parse latest Terraform version into variables
id: latest_version
run: |-
TERRAFORM_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_TERRAFORM_VERSION")
echo "value=$NEW_TERRAFORM_VERSION" >> $GITHUB_OUTPUT
echo "minor=$TERRAFORM_VERSION_MINOR" >> $GITHUB_OUTPUT
- name: Run upgrade script
if: steps.current_version.outputs.value != steps.latest_version.outputs.value
run: scripts/update-terraform.sh ${{ steps.latest_version.outputs.value }}
- name: Get the latest version of this GitHub Action from git
id: github_action
if: steps.current_version.outputs.minor != steps.latest_version.outputs.minor
run: echo "version=$(git describe --tags | cut -d "-" -f 1)" >> $GITHUB_OUTPUT
- name: Update the README for a breaking change
if: steps.current_version.outputs.minor != steps.latest_version.outputs.minor
env:
GHA_VERSION: ${{ steps.github_action.outputs.version }}
run: |-
GHA_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$GHA_VERSION" | cut -c2-)
NEW_GHA_VERSION=$((GHA_VERSION_MAJOR + 1))
sed -i 's/terraform-cdk-action@v.*/terraform-cdk-action@v'"$NEW_GHA_VERSION"'/' "./README.md"
- name: Create pull request for a breaking change
if: steps.current_version.outputs.minor != steps.latest_version.outputs.minor
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f
with:
branch: auto/upgrade-terraform-1-${{ steps.latest_version.outputs.minor }}
base: main
labels: automerge,dependencies
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
author: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
committer: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
signoff: true
delete-branch: true
commit-message: "chore!: change default Terraform version to ${{ steps.latest_version.outputs.value }}"
title: "chore!: change default Terraform version to ${{ steps.latest_version.outputs.value }}"
body: |-
This PR increases the default version of Terraform used from `${{ steps.current_version.outputs.value }}` to version `${{ steps.latest_version.outputs.value }}`.
This is considered a breaking change because anyone who does not manually specify a `terraformVersion` in their action configuration will automatically start using the new version.
- name: Create pull request for a non-breaking change
if: steps.current_version.outputs.minor == steps.latest_version.outputs.minor
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f
with:
branch: auto/upgrade-terraform-1-${{ steps.latest_version.outputs.minor }}
base: main
labels: automerge,dependencies,auto-approve
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
author: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
committer: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
signoff: true
delete-branch: true
commit-message: "fix: change default Terraform version to ${{ steps.latest_version.outputs.value }}"
title: "fix: change default Terraform version to ${{ steps.latest_version.outputs.value }}"
body: |-
This PR increases the default version of Terraform used from `${{ steps.current_version.outputs.value }}` to version `${{ steps.latest_version.outputs.value }}`.
This is not considered a breaking change because it's just a patch release that shouldn't have any backwards incompatibilities.