-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GHA: Add post-release workflow that updates AMI IDs (#23583)
Co-authored-by: Victor Sokolov <[email protected]>
- Loading branch information
1 parent
3e66c44
commit 2e180e4
Showing
2 changed files
with
90 additions
and
6 deletions.
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 |
---|---|---|
@@ -1,11 +1,51 @@ | ||
name: Post-release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
|
||
jobs: | ||
dummy: | ||
release: | ||
name: Collect release information | ||
outputs: | ||
type: ${{ steps.artifacts.outputs.type }} | ||
version: ${{ steps.artifacts.outputs.version }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Greeting | ||
run: echo "This is a dummy build to placate GitHub." | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ vars.GITHUB_REF }} | ||
|
||
# Release event metadata doesn't include "is latest" flag so we have | ||
# to determine it another way. | ||
- name: Determine release latest flag and version | ||
id: artifacts | ||
run: | | ||
LATEST_RELEASE_ID=$(gh release view --json id | jq '.id' | tr -d \") | ||
CURRENT_RELEASE_ID=${{ github.event.release.node_id }} | ||
if [ $LATEST_RELEASE_ID == $CURRENT_RELEASE_ID ]; then | ||
echo "type=latest" >> $GITHUB_OUTPUT | ||
else | ||
echo "type=other" >> $GITHUB_OUTPUT | ||
fi | ||
echo "version=$(make --no-print-directory print-version)" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
update-ami-ids: | ||
name: Update AMI IDs | ||
needs: release | ||
if: needs.release.outputs.type == 'latest' | ||
uses: ./.github/workflows/update-ami-ids.yml | ||
with: | ||
version: ${{ needs.release.outputs.version }} |
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 |
---|---|---|
|
@@ -2,10 +2,54 @@ name: Update AMI IDs | |
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
required: true | ||
type: string | ||
description: Release version tag (ex. 12.1.0) | ||
|
||
workflow_call: | ||
inputs: | ||
version: | ||
required: true | ||
type: string | ||
description: Release version tag (ex. 12.1.0) | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
|
||
jobs: | ||
dummy: | ||
update-ami-ids: | ||
name: Update AMI IDs | ||
runs-on: ubuntu-latest | ||
environment: post-release | ||
|
||
steps: | ||
- name: Greeting | ||
run: echo "This is a dummy build to placate GitHub." | ||
- name: Generate Github token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ vars.APP_ID }} | ||
private_key: ${{ secrets.PRIVATE_KEY }} | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
|
||
- name: Assume AWS role | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-region: us-west-2 | ||
role-to-assume: "arn:aws:iam::126027368216:role/tf-teleport-ami-gha-role" | ||
role-session-name: "gha-update-ami-ids-${{ github.run_number }}" | ||
|
||
- name: Update AMI IDs and create PR | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub" | ||
TELEPORT_VERSION=${{ inputs.version }} make -C assets/aws create-update-pr | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} |