Skip to content

Commit 2cf223d

Browse files
authored
chore(ci): prevent concurrent git update in critical workflows (#1478)
1 parent 48b504f commit 2cf223d

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

.github/workflows/build_changelog.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Standalone workflow to update changelog if necessary
2+
name: Build changelog
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
changelog:
9+
needs: release
10+
uses: ./.github/workflows/reusable_publish_changelog.yml

.github/workflows/publish.yml renamed to .github/workflows/on_release_notes.yml

+14-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ name: Publish to PyPi
2020

2121
# See MAINTAINERS.md "Releasing a new version" for release mechanisms
2222

23+
env:
24+
BRANCH: develop
25+
2326
on:
2427
release:
2528
types: [published]
@@ -101,17 +104,14 @@ jobs:
101104
aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_VERSION --overwrite
102105
aws codepipeline start-pipeline-execution --name ${{ secrets.AWS_SAR_PIPELINE_NAME }}
103106
104-
# NOTE: `event` type brings a detached head failing git setup
105-
# and reusable workflows only work as a standalone job
106-
# meaning we need to research for a solution that works for non-detached and detached mode
107-
# changelog:
108-
# needs: release
109-
# permissions:
110-
# contents: write
111-
# uses: ./.github/workflows/reusable_publish_changelog.yml
107+
changelog:
108+
needs: release
109+
permissions:
110+
contents: write
111+
uses: ./.github/workflows/reusable_publish_changelog.yml
112112

113113
docs:
114-
needs: release
114+
needs: [release, changelog]
115115
permissions:
116116
contents: write
117117
pages: write
@@ -122,10 +122,13 @@ jobs:
122122
- uses: actions/checkout@v3
123123
with:
124124
fetch-depth: 0
125-
- name: Setup git client
125+
- name: Git client setup and refresh tip
126126
run: |
127127
git config user.name "Release bot"
128-
git config user.email aws-devax-open-source@amazon.com
128+
git config user.email "aws-devax-open-source@amazon.com"
129+
git config pull.rebase true
130+
git config remote.origin.url >&- || git remote add origin https://github.com/$origin # Git Detached mode (release notes) doesn't have origin
131+
git pull origin $BRANCH
129132
- name: Install poetry
130133
run: pipx install poetry
131134
- name: Set up Python

.github/workflows/reusable_publish_changelog.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
permissions:
77
contents: write
88

9+
env:
10+
BRANCH: develop
11+
912
jobs:
1013
publish_changelog:
1114
# Force Github action to run only a single job at a time (based on the group name)
@@ -23,11 +26,13 @@ jobs:
2326
git config user.name "Release bot"
2427
git config user.email "aws-devax-open-source@amazon.com"
2528
git config pull.rebase true
26-
git pull --rebase
29+
git config remote.origin.url >&- || git remote add origin https://github.com/$origin # Git Detached mode (release notes) doesn't have origin
30+
git pull origin $BRANCH
2731
- name: "Generate latest changelog"
2832
run: make changelog
2933
- name: Update Changelog in trunk
3034
run: |
3135
git add CHANGELOG.md
3236
git commit -m "update changelog with latest changes"
33-
git push origin HEAD:refs/heads/develop
37+
git pull origin $BRANCH # prevents concurrent branch update failing push
38+
git push origin HEAD:refs/heads/$BRANCH

0 commit comments

Comments
 (0)