Skip to content
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

chore(ci): prevent concurrent git update in critical workflows #1478

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Standalone workflow to update changelog if necessary
name: Build changelog

on:
workflow_dispatch:

jobs:
changelog:
needs: release
uses: ./.github/workflows/reusable_publish_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ name: Publish to PyPi

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

env:
BRANCH: develop

on:
release:
types: [published]
Expand Down Expand Up @@ -101,17 +104,14 @@ jobs:
aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_VERSION --overwrite
aws codepipeline start-pipeline-execution --name ${{ secrets.AWS_SAR_PIPELINE_NAME }}

# NOTE: `event` type brings a detached head failing git setup
# and reusable workflows only work as a standalone job
# meaning we need to research for a solution that works for non-detached and detached mode
# changelog:
# needs: release
# permissions:
# contents: write
# uses: ./.github/workflows/reusable_publish_changelog.yml
changelog:
needs: release
permissions:
contents: write
uses: ./.github/workflows/reusable_publish_changelog.yml

docs:
needs: release
needs: [release, changelog]
permissions:
contents: write
pages: write
Expand All @@ -122,10 +122,13 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup git client
- name: Git client setup and refresh tip
run: |
git config user.name "Release bot"
git config user.email [email protected]
git config user.email "[email protected]"
git config pull.rebase true
git config remote.origin.url >&- || git remote add origin https://github.com/$origin # Git Detached mode (release notes) doesn't have origin
git pull origin $BRANCH
- name: Install poetry
run: pipx install poetry
- name: Set up Python
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/reusable_publish_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
permissions:
contents: write

env:
BRANCH: develop

jobs:
publish_changelog:
# Force Github action to run only a single job at a time (based on the group name)
Expand All @@ -23,11 +26,13 @@ jobs:
git config user.name "Release bot"
git config user.email "[email protected]"
git config pull.rebase true
git pull --rebase
git config remote.origin.url >&- || git remote add origin https://github.com/$origin # Git Detached mode (release notes) doesn't have origin
git pull origin $BRANCH
- name: "Generate latest changelog"
run: make changelog
- name: Update Changelog in trunk
run: |
git add CHANGELOG.md
git commit -m "update changelog with latest changes"
git push origin HEAD:refs/heads/develop
git pull origin $BRANCH # prevents concurrent branch update failing push
git push origin HEAD:refs/heads/$BRANCH