Skip to content

Commit c527556

Browse files
authored
Use bot to execute Pre and Post release schedule (#166)
*Description of changes:* For code clean purpose, update the role ARN's name Add a bot account and use the bot account's token to perform workflow update in pre and post-release. That have two benefits: 1. Allow modify workflow file for post release 2. Create PR with bot account will automatically trigger check workflows Tested functional: Modified post-release runs: https://github.com/XinRanZhAWS/aws-otel-python-instrumentation/actions/runs/8837317974 PR created with check enabled: XinRanZhAWS/aws-otel-python-instrumentation#20 Modified pre-release runs: https://github.com/XinRanZhAWS/aws-otel-python-instrumentation/actions/runs/8837526972 PR created with check enabled: XinRanZhAWS/aws-otel-python-instrumentation#19 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent e042cfe commit c527556

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

.github/workflows/post_release_version_bump.yml

+22-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ on:
77
description: 'Version number (e.g., 1.0.1)'
88
required: true
99

10+
env:
11+
AWS_DEFAULT_REGION: us-east-1
12+
1013
permissions:
14+
id-token: write
1115
contents: write
1216
pull-requests: write
1317

@@ -31,7 +35,7 @@ jobs:
3135
run: |
3236
CURRENT_VERSION=$(grep '__version__' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | sed -E 's/__version__ = "([0-9]+\.[0-9]+)\.[0-9]+.*"/\1/')
3337
echo "CURRENT_MAJOR_MINOR_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
34-
38+
3539
- name: Set major and minor for current version
3640
run: |
3741
echo "CURRENT_MAJOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f1)" >> $GITHUB_ENV
@@ -48,16 +52,31 @@ jobs:
4852
echo "Input version is behind main's current major.minor version, don't need to update major version"
4953
exit 1
5054
fi
51-
55+
5256

5357
prepare-main:
5458
runs-on: ubuntu-latest
5559
needs: check-version
5660
steps:
61+
- name: Configure AWS credentials for BOT secrets
62+
uses: aws-actions/configure-aws-credentials@v4
63+
with:
64+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
65+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
66+
67+
- name: Get Bot secrets
68+
uses: aws-actions/aws-secretsmanager-get-secrets@v1
69+
id: bot_secrets
70+
with:
71+
secret-ids: |
72+
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
73+
parse-json-secrets: true
74+
5775
- name: Setup Git
5876
uses: actions/checkout@v2
5977
with:
6078
fetch-depth: 0
79+
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
6180

6281
- name: Configure Git
6382
run: |
@@ -88,7 +107,7 @@ jobs:
88107
89108
- name: Create Pull Request to main
90109
env:
91-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
92111
run: |
93112
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
94113
gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \

.github/workflows/pre_release_prepare.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ on:
1111
required: true
1212
default: 'false'
1313

14+
env:
15+
AWS_DEFAULT_REGION: us-east-1
16+
1417
permissions:
1518
contents: write
1619
pull-requests: write
20+
id-token: write
1721

1822

1923
jobs:
2024
update-version-and-create-pr:
2125
runs-on: ubuntu-latest
2226
steps:
27+
- name: Configure AWS credentials for BOT secrets
28+
uses: aws-actions/configure-aws-credentials@v4
29+
with:
30+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
31+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
32+
33+
- name: Get Bot secrets
34+
uses: aws-actions/aws-secretsmanager-get-secrets@v1
35+
id: bot_secrets
36+
with:
37+
secret-ids: |
38+
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
39+
parse-json-secrets: true
40+
2341
- name: Checkout main branch
2442
uses: actions/checkout@v3
2543
with:
2644
ref: 'main'
45+
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
2746

2847
- name: Setup Git
2948
run: |
@@ -77,7 +96,7 @@ jobs:
7796
7897
- name: Create pull request against the release branch
7998
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
81100
run: |
82101
gh pr create --title "Pre-release: Update version to ${VERSION}" \
83102
--body "This PR updates the version to ${VERSION}.

.github/workflows/release_build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Configure AWS credentials for PyPI secrets
4545
uses: aws-actions/configure-aws-credentials@v4
4646
with:
47-
role-to-assume: ${{ secrets.AWS_ROLE_ARN_PYPI_RELEASE }}
47+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
4848
aws-region: ${{ env.AWS_DEFAULT_REGION }}
4949

5050
- name: Get PyPI secrets

0 commit comments

Comments
 (0)