-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: automate upgrading CDKTF #222
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: upgrade-cdktf | ||
on: | ||
schedule: | ||
- cron: 13 */6 * * * | ||
workflow_dispatch: {} | ||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
jobs: | ||
check_versions: | ||
name: Check CDKTF versions | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- name: Install | ||
run: yarn install | ||
- name: Get current CDKTF version | ||
id: current_version | ||
# NOTE: This uses the version in projenrc.template.js as the source of truth (and not the version of cdktf in the repo-manager's package.json) | ||
run: |- | ||
OLD_VERSION=$(sed -nE 's/cdktfVersion: "\^(.*)",/\1/p' projenrc.template.js | xargs) | ||
OLD_VERSION_MINOR=$(cut -d "." -f 2 <<< "$OLD_VERSION") | ||
echo "value=$OLD_VERSION" >> $GITHUB_OUTPUT | ||
echo "short=$OLD_VERSION_MINOR" >> $GITHUB_OUTPUT | ||
- name: Get latest CDKTF version | ||
id: latest_version | ||
run: |- | ||
CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version') | ||
CDKTF_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CDKTF_VERSION") | ||
echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT | ||
echo "short=$CDKTF_VERSION_MINOR" >> $GITHUB_OUTPUT | ||
outputs: | ||
current_version: ${{ steps.current_version.outputs.value }} | ||
current_version_minor: ${{ steps.current_version.outputs.short }} | ||
latest_version: ${{ steps.latest_version.outputs.value }} | ||
latest_version_minor: ${{ steps.latest_version.outputs.short }} | ||
upgrade_repos: | ||
name: Upgrade CDKTF in prebuilt provider repos | ||
runs-on: ubuntu-latest | ||
needs: [check_versions] | ||
if: needs.check_versions.outputs.current_version_minor != needs.check_versions.outputs.latest_version_minor | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- name: Do the upgrade | ||
run: | | ||
sed -i "s/cdktfVersion: \".*\",/cdktfVersion: \"^$NEW_CDKTF_VERSION\",/" ./projenrc.template.js | ||
env: | ||
NEW_CDKTF_VERSION: ${{ needs.check_versions.outputs.latest_version }} | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 # v5.0.1 | ||
with: | ||
branch: auto/upgrade-cdktf-${{ needs.check_versions.outputs.latest_version_minor }} | ||
base: main | ||
commit-message: "feat!: upgrade providers to CDKTF version ${{ needs.check_versions.outputs.latest_version }}" | ||
title: "feat!: upgrade providers to CDKTF version ${{ needs.check_versions.outputs.latest_version }}" | ||
body: This PR upgrades CDKTF from version `${{ needs.check_versions.outputs.current_version }}` to version `${{ needs.check_versions.outputs.latest_version }}` in the prebuilt providers managed by this project. | ||
labels: automated | ||
token: ${{ secrets.GH_TOKEN_ACTIONS_UPDATER }} | ||
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 | ||
outputs: | ||
pr_id: ${{ steps.cpr.outputs.pull-request-number }} | ||
upgrade_self: | ||
name: Upgrade CDKTF in repository-manager | ||
runs-on: ubuntu-latest | ||
needs: [check_versions, upgrade_repos] | ||
if: needs.check_versions.outputs.current_version_minor != needs.check_versions.outputs.latest_version_minor | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- name: Install | ||
run: yarn install | ||
- name: Do the upgrade | ||
run: | | ||
yarn add cdktf@^$NEW_CDKTF_VERSION | ||
yarn add cdktf-cli@^$NEW_CDKTF_VERSION | ||
env: | ||
NEW_CDKTF_VERSION: ${{ needs.check_versions.outputs.latest_version }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 # v5.0.1 | ||
with: | ||
branch: auto/upgrade-cdktf-${{ needs.check_versions.outputs.latest_version_minor }} | ||
base: main | ||
commit-message: "chore: upgrade self to cdktf ${{ needs.check_versions.outputs.latest_version }}" | ||
title: "chore: upgrade self to cdktf ${{ needs.check_versions.outputs.latest_version }}" | ||
body: | | ||
This PR upgrades CDKTF to version `${{ needs.check_versions.outputs.latest_version }}` in `cdktf-repository-manager` (this repo). | ||
Unfortunately, not everything can be automated, and the following steps need to be completed manually: | ||
|
||
- [ ] Wait for #${{ needs.upgrade_repos.outputs.pr_id }} to be merged and for the deployment to succeed | ||
- [ ] Upgrade `@cdktf/provider-github` to a version compatible with `cdktf@${{ needs.check_versions.outputs.latest_version }}` (`yarn add ...`) | ||
|
||
Please checkout this PR, complete the above steps, push the changes to this branch, and then mark this PR as ready for review to complete the upgrade. Thanks! | ||
labels: automerge,automated,dependencies | ||
token: ${{ secrets.GH_TOKEN_ACTIONS_UPDATER }} | ||
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 | ||
draft: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.