generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 141
Adding release kickoff github actions and introduce new release config JSON fields #1036
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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,91 @@ | ||
| name: InitiateRelease | ||
|
|
||
| # TODO: We will be changing this to run on a regular scheduled interval once all of the infrastructure has been set up. | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| GenerateConfig: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| stage_exit_code: ${{ steps.stage.outputs.stage_exit_code }} | ||
| push_exit_code: ${{ steps.push.outputs.push_exit_code }} | ||
| pr_exit_code: ${{ steps.pr.outputs.pr_exit_code }} | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| pull-requests: write | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Create Release Branch | ||
| run: | | ||
| date=$(date '+%Y%m%d') | ||
| git checkout -b release-${date} | ||
| - name: Configure Bot Alias | ||
| run: | | ||
| git config --global user.name "GenerateConfig Action" | ||
| git config --global user.email "gcabot@github.com" | ||
| - name: Check Update | ||
| run: ./scripts/check-update.sh | ||
| - name: Check for changes | ||
| id: stage | ||
| run: | | ||
| # Git diff returns exit code of 1 when there is a change staged | ||
| # We need the set statements to prevent erroring out | ||
| set +e | ||
| git diff --cached --quiet | ||
| if [[ $? -ne 0 ]]; then echo "stage_exit_code=42" >> "$GITHUB_OUTPUT"; else echo "stage_exit_code=0" >> "$GITHUB_OUTPUT"; fi | ||
| set -e | ||
| - name: Commit and Push Changes | ||
| id: push | ||
| if: ${{ steps.stage.outputs.stage_exit_code == 42 }} | ||
| run: | | ||
| date=$(date '+%Y%m%d') | ||
| git commit -m "Release ${date}" | ||
| git status | ||
| git push --set-upstream origin release-${date} | ||
| echo "push_exit_code=$?" >> "$GITHUB_OUTPUT" | ||
| - name: Open PR for Branch | ||
| id: pr | ||
| if: ${{ steps.stage.outputs.stage_exit_code == 42 && steps.push.outputs.push_exit_code == 0 }} | ||
| run: | | ||
| date=$(date '+%Y%m%d') | ||
| gh pr create --base mainline --head release-${date} --title "Release ${date}" --body "Dummy Release PR" | ||
| echo "pr_exit_code=$?" >> "$GITHUB_OUTPUT" | ||
| MetricPublish: | ||
| needs: GenerateConfig | ||
| if: success() || failure() | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| # TODO: Add the role as a secret once infrastructure has been set up. | ||
| role-to-assume: ${{ secrets.CW_METRIC_ROLE }} | ||
| aws-region: us-west-2 | ||
| - name: Failure Scenario | ||
| if: ${{ needs.GenerateConfig.result == 'failure' }} | ||
| run: | | ||
| # TODO: Cloudwatch metric namespace will need to be created | ||
| echo "ERROR: Encounter error when checking for new release." | ||
| aws cloudwatch put-metric-data --metric-name FluentBitGithubActionFailure --namespace FluentBitRelease --value "-1" | ||
| - name: Release Kickoff Scenario | ||
| if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 42 }} | ||
| run: | | ||
| # TODO: Cloudwatch metric namespace will need to be created | ||
| echo "Kicking off new release." | ||
| aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 1 | ||
| - name: No Release Scenario | ||
| if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 0 }} | ||
| run: | | ||
| # TODO: Cloudwatch metric namespace will need to be created | ||
| echo "No new release needed at this time." | ||
| aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0 | ||
This file contains hidden or 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,27 @@ | ||
| name: Post-release merge action | ||
| run-name: Post-release merge action | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: [mainline] | ||
|
|
||
| jobs: | ||
| ResetReleaseMetric: | ||
| if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Run on merged PR | ||
| run: echo "PR merged from ${{ github.head_ref }} to ${{ github.base_ref }}" | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| # TODO: Add the role as a secret once infrastructure has been set up. | ||
| role-to-assume: ${{ secrets.CW_METRIC_ROLE }} | ||
| aws-region: us-west-2 | ||
| - name: Reset release alarm | ||
| run: aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0 |
This file contains hidden or 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
This file contains hidden or 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,77 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| readonly VERSION_FILE="linux.version" | ||
| readonly ECR_REPO="public.ecr.aws/amazonlinux/amazonlinux" | ||
|
|
||
| # List of docker tags that we want to clean up after | ||
| tags_to_cleanup=() | ||
|
|
||
| # Cleanup function that removes the pulled AL docker images | ||
| cleanup() { | ||
| for i in "${tags_to_cleanup[@]}"; do | ||
| docker rmi "${ECR_REPO}:$i" || true | ||
| done | ||
| } | ||
|
|
||
| # Helper function to update the specific JSON key/field within the release config file | ||
| update_json_field() { | ||
| local key="$1" field="$2" value="$3" | ||
| jq ".[$key].linux.\"$field\" = \"$value\"" "$VERSION_FILE" > tmp.json && mv tmp.json "$VERSION_FILE" | ||
| } | ||
|
|
||
| # Function that checks and updates the release config file for any of the following: | ||
| # - New Amazon Linux docker image (tracked by image SHA) | ||
| # - New upstream Fluentbit version to consumed | ||
| # - New AWS Fluentbit version to be released (Updated to pull in any other updates/changes.) | ||
| check_and_update() { | ||
| local update="false" | ||
|
|
||
| for i in $(jq 'keys[]' "$VERSION_FILE"); do | ||
| current_sha=$(jq -r ".[$i].linux.\"amazon-linux-sha\"" "$VERSION_FILE") | ||
| tag=$(jq -r ".[$i].linux.\"al-tag\"" "$VERSION_FILE") | ||
|
|
||
| if ! docker pull "${ECR_REPO}:$tag"; then | ||
| echo "Warning: Failed to pull ${ECR_REPO}:$tag" >&2 | ||
| continue | ||
| fi | ||
|
|
||
| tags_to_cleanup+=("$tag") | ||
| new_al_sha=$(docker inspect --format='{{index .RepoDigests 0}}' "${ECR_REPO}:$tag") | ||
|
|
||
| if [[ "$new_al_sha" != "$current_sha" ]]; then | ||
| echo "New base amazon linux image for $tag. Updating..." | ||
| update_json_field "$i" "amazon-linux-sha" "$new_al_sha" | ||
| update="true" | ||
| fi | ||
|
|
||
| curr_fluentbit_version=$(jq -r ".[$i].linux.\"fluent-bit\"" "$VERSION_FILE") | ||
| release_fluentbit_version=$(jq -r ".[$i].linux.\"release-fluent-bit\"" "$VERSION_FILE") | ||
| if [[ "$curr_fluentbit_version" != "$release_fluentbit_version" ]]; then | ||
| echo "Upgrading to new Fluentbit version." | ||
| update_json_field "$i" "fluent-bit" "$release_fluentbit_version" | ||
| update="true" | ||
| fi | ||
|
|
||
| curr_aws_fb_version=$(jq -r ".[$i].linux.\"version\"" "$VERSION_FILE") | ||
| release_aws_fb_version=$(jq -r ".[$i].linux.\"release-version\"" "$VERSION_FILE") | ||
| if [[ "$curr_aws_fb_version" != "$release_aws_fb_version" ]]; then | ||
| echo "Upgrading to new AWS Fluentbit version." | ||
| update_json_field "$i" "version" "$release_aws_fb_version" | ||
| update="true" | ||
| fi | ||
| done | ||
|
|
||
| if [[ "$update" = "true" ]]; then | ||
| git add "$VERSION_FILE" | ||
| git status | ||
| fi | ||
| } | ||
|
|
||
| main() { | ||
| check_and_update | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| main "$@" |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a new bot account we are setting up? should it be @amazon.com?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good q. no it's not, you can think of it as a "dummy user" like we do in https://github.com/aws/amazon-ecs-ami/blob/8fb9159108e9682a84d830c34f866fc08710a9d7/.github/workflows/initiaterelease.yml#L40-L41