forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: mergeit-backport | ||
|
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- labeled | ||
branches: | ||
- main | ||
jobs: | ||
changelog_types: | ||
permissions: | ||
pull-requests: read | ||
runs-on: ubuntu-latest | ||
outputs: | ||
no_backport: ${{ steps.fetch.outputs.no_backport }} | ||
bugfix: ${{ steps.fetch.outputs.bugfix }} | ||
minor_only: ${{ steps.fetch.outputs.minor_only }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Fetch change types from changelog fragments | ||
id: fetch | ||
shell: bash {0} | ||
run: | | ||
gh pr -R "${GITHUB_REPOSITORY}" diff "${{ github.event.pull_request.number }}" --name-only | \ | ||
grep -E '^changelogs/fragments/' | \ | ||
while read -r line | ||
do cat "${line}" | \ | ||
python -c 'import sys, yaml; change = yaml.safe_load(sys.stdin.read()) ; print("\n".join(change.keys()));' \ | ||
| tee -a all-changelog-types | ||
done | ||
# Beware, these a bash-ian booleans: "true == 0" | ||
grep -qE '(release_summary|breaking_changes|major_changes|removed_features)' all-changelog-types ; echo "no_backport=${?}" >>${GITHUB_OUTPUT} | ||
grep -qE '(bugfixes|security_fixes)' all-changelog-types ; echo "bugfix=${?}" >>${GITHUB_OUTPUT} | ||
grep -qE '(deprecated_features|minor_changes)' all-changelog-types ; echo "minor_only=${?}" >>${GITHUB_OUTPUT} | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
changelog_labeling: | ||
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
needs: | ||
- changelog_types | ||
steps: | ||
- run: | ||
if [[ ${NO_BACKPORT} == 0 ]] ; then echo ${BACKPORT_FORBIDDEN} ; exit 0 ; fi | ||
# If we include something that needs a "minor" release, we probably should be | ||
# automatically backporting it | ||
if [[ ${MINOR_ONLY} == 0 ]] ; then echo ${BACKPORT_CURRENT} ; exit 0 ; fi | ||
# If we include a bug/security fix, then we should backport to the bugfix branch | ||
if [[ ${BUGFIX} == 0 ]] ; then echo ${BACKPORT_BUGFIX} ${BACKPORT_CURRENT} ; exit 0 ; fi | ||
# Default to backporting to the current "stable" release | ||
echo ${BACKPORT_BUGFIX} | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
NO_BACKPORT: ${{ needs.changelog_types.outputs.no_backport }} | ||
BUGFIX: ${{ needs.changelog_types.outputs.bugfix }} | ||
MINOR_ONLY: ${{ needs.changelog_types.outputs.minor_only }} | ||
# These should be updated as part of the MAJOR release process | ||
BACKPORT_CURRENT: 'backport-9' | ||
BACKPORT_BUGFIX: 'backport-8' | ||
BACKPORT_FORBIDDEN: 'do_not_backport' |