|
| 1 | +name: InitiateRelease |
| 2 | + |
| 3 | +# TODO: We will be changing this to run on a regular scheduled interval once all of the infrastructure has been set up. |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + GenerateConfig: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + stage_exit_code: ${{ steps.stage.outputs.stage_exit_code }} |
| 12 | + push_exit_code: ${{ steps.push.outputs.push_exit_code }} |
| 13 | + pr_exit_code: ${{ steps.pr.outputs.pr_exit_code }} |
| 14 | + permissions: |
| 15 | + id-token: write |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + env: |
| 19 | + GH_TOKEN: ${{ github.token }} |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v5 |
| 23 | + - name: Create Release Branch |
| 24 | + run: | |
| 25 | + date=$(date '+%Y%m%d') |
| 26 | + git checkout -b release-${date} |
| 27 | + - name: Configure Bot Alias |
| 28 | + run: | |
| 29 | + git config --global user.name "GenerateConfig Action" |
| 30 | + git config --global user.email "[email protected]" |
| 31 | + - name: Check Update |
| 32 | + run: ./scripts/check-update.sh |
| 33 | + - name: Check for changes |
| 34 | + id: stage |
| 35 | + run: | |
| 36 | + # Git diff returns exit code of 1 when there is a change staged |
| 37 | + # We need the set statements to prevent erroring out |
| 38 | + set +e |
| 39 | + git diff --cached --quiet |
| 40 | + if [[ $? -ne 0 ]]; then echo "stage_exit_code=42" >> "$GITHUB_OUTPUT"; else echo "stage_exit_code=0" >> "$GITHUB_OUTPUT"; fi |
| 41 | + set -e |
| 42 | + - name: Commit and Push Changes |
| 43 | + id: push |
| 44 | + if: ${{ steps.stage.outputs.stage_exit_code == 42 }} |
| 45 | + run: | |
| 46 | + date=$(date '+%Y%m%d') |
| 47 | + git commit -m "Release ${date}" |
| 48 | + git status |
| 49 | + git push --set-upstream origin release-${date} |
| 50 | + echo "push_exit_code=$?" >> "$GITHUB_OUTPUT" |
| 51 | + - name: Open PR for Branch |
| 52 | + id: pr |
| 53 | + if: ${{ steps.stage.outputs.stage_exit_code == 42 && steps.push.outputs.push_exit_code == 0 }} |
| 54 | + run: | |
| 55 | + date=$(date '+%Y%m%d') |
| 56 | + gh pr create --base mainline --head release-${date} --title "Release ${date}" --body "Dummy Release PR" |
| 57 | + echo "pr_exit_code=$?" >> "$GITHUB_OUTPUT" |
| 58 | + MetricPublish: |
| 59 | + needs: GenerateConfig |
| 60 | + if: success() || failure() |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + id-token: write |
| 64 | + contents: read |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v5 |
| 68 | + - name: Configure AWS Credentials |
| 69 | + uses: aws-actions/configure-aws-credentials@v5 |
| 70 | + with: |
| 71 | + # TODO: Add the role as a secret once infrastructure has been set up. |
| 72 | + role-to-assume: ${{ secrets.CW_METRIC_ROLE }} |
| 73 | + aws-region: us-west-2 |
| 74 | + - name: Failure Scenario |
| 75 | + if: ${{ needs.GenerateConfig.result == 'failure' }} |
| 76 | + run: | |
| 77 | + # TODO: Cloudwatch metric namespace will need to be created |
| 78 | + echo "ERROR: Encounter error when checking for new release." |
| 79 | + aws cloudwatch put-metric-data --metric-name FluentBitGithubActionFailure --namespace FluentBitRelease --value "-1" |
| 80 | + - name: Release Kickoff Scenario |
| 81 | + if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 42 }} |
| 82 | + run: | |
| 83 | + # TODO: Cloudwatch metric namespace will need to be created |
| 84 | + echo "Kicking off new release." |
| 85 | + aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 1 |
| 86 | + - name: No Release Scenario |
| 87 | + if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 0 }} |
| 88 | + run: | |
| 89 | + # TODO: Cloudwatch metric namespace will need to be created |
| 90 | + echo "No new release needed at this time." |
| 91 | + aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0 |
0 commit comments