-
Notifications
You must be signed in to change notification settings - Fork 147
90 lines (88 loc) · 3.4 KB
/
Copy pathinitiaterelease.yml
File metadata and controls
90 lines (88 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: InitiateRelease
on:
workflow_dispatch:
schedule:
# Run at 6PM UTC (10AM PST) M-F
- cron: 0 18 * * 1-5
jobs:
GenerateConfig:
if: github.repository == 'aws/aws-for-fluent-bit'
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 "AWS Fluentbit Release Kickoff"
echo "pr_exit_code=$?" >> "$GITHUB_OUTPUT"
MetricPublish:
needs: GenerateConfig
if: (success() || failure()) && github.repository == 'aws/aws-for-fluent-bit'
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:
role-to-assume: ${{ secrets.CW_METRIC_ROLE }}
aws-region: us-west-2
- name: Failure Scenario
if: ${{ needs.GenerateConfig.result == 'failure' }}
run: |
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: |
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: |
echo "No new release needed at this time."
aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0