-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to github actions to support slack notifs and gitflow branching
- Loading branch information
1 parent
d7475fb
commit b7039ca
Showing
5 changed files
with
219 additions
and
2 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,56 @@ | ||
name: Draft Release and Tag | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
draft_release: | ||
runs-on: ubuntu-latest | ||
if: (startsWith(github.event.pull_request.head.ref, 'release/' ) || startsWith(github.event.pull_request.head.ref, 'hotfix/')) && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | ||
steps: | ||
- name: Checkout Source Tag | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
- name: Get Version | ||
id: get-version | ||
run: | | ||
version=$(echo ${{github.event.pull_request.head.ref}} | cut -d/ -f2) | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "VERSION = $version" | ||
- name: Create Release | ||
run: | | ||
gh release create ${{ steps.get-version.outputs.version }} --generate-notes -d -t "${{ steps.get-version.outputs.version }}" --target main | ||
env: | ||
GH_TOKEN: ${{ secrets.LEAD_ACCESS_TOKEN }} | ||
send_final_slack_notification: | ||
name: Send Final Slack Notification | ||
needs: [draft_release] | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: Get Version | ||
id: get-version | ||
run: | | ||
version=$(echo ${{github.event.pull_request.head.ref}} | cut -d/ -f2) | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "VERSION = $version" | ||
- name: Send Notification that Draft Release is Ready | ||
uses: rtCamp/action-slack-notify@v2 | ||
if: (startsWith(github.event.pull_request.head.ref, 'release/' ) || startsWith(github.event.pull_request.head.ref, 'hotfix/')) && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' | ||
with: | ||
status: success() | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_COLOR: ${{ contains(join(needs.*.result, ' '), 'failure') && 'failure' || 'success' }} | ||
SLACK_TITLE: 'Build Finished' | ||
SLACK_FOOTER: '' | ||
MSG_MINIMAL: true | ||
SLACK_MESSAGE_ON_FAILURE: '<!here> FAILED to publish Draft release for ${{ steps.get-version.outputs.version }}' | ||
SLACK_MESSAGE_ON_SUCCESS: '<!here> Draft release published for <https://github.com/awslabs/LISA/releases|${{ steps.get-version.outputs.version }}>' | ||
SLACK_MESSAGE: '<!here> Draft release finished with status ${{ job.status }} for ${{ steps.get-version.outputs.version }}' |
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,43 @@ | ||
name: Make Hotfix Branch | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
source_tag: | ||
description: 'Starting Tag' | ||
required: true | ||
dest_tag: | ||
description: 'New Tag' | ||
required: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
MakeNewBranch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Source Tag | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: refs/tags/${{ github.event.inputs.source_tag }} | ||
- name: Create Hotfix Branch and Update Version | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "github_actions_lisa" | ||
SRC_TAG=${{ github.event.inputs.source_tag }} | ||
DST_TAG=${{ github.event.inputs.dest_tag }} | ||
git checkout -b hotfix/${{ github.event.inputs.dest_tag }} | ||
sed -i -e "s/\"version\": \"${SRC_TAG:1}\"/\"version\": \"${DST_TAG:1}\"/g" package.json | ||
sed -i -e "s/version = \"${SRC_TAG:1}\"/version = \"${DST_TAG:1}\"/g" lisa-sdk/pyproject.toml | ||
sed -i -e "s/${SRC_TAG:1}/${DST_TAG:1}/g" VERSION | ||
git commit -a -m "Updating version for hotfix ${{ github.event.inputs.dest_tag }}" | ||
git push origin hotfix/${{ github.event.inputs.dest_tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.LEAD_ACCESS_TOKEN }} | ||
- name: Draft Pull Request | ||
run: | | ||
gh pr create -d --title "Hotfix ${{github.event.inputs.dest_tag}} into Main" --body "Hotfix ${{github.event.inputs.dest_tag}} PR into Main" --base main --head hotfix/${{ github.event.inputs.dest_tag }} | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
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,46 @@ | ||
name: Merge Main into Develop | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
conduct_merge: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
- name: merge main into develop | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "github_actions_lisa" | ||
git fetch --unshallow | ||
git checkout develop | ||
git pull | ||
git merge --no-ff origin/main -m "Auto-merge main back to dev post release" | ||
git push --force origin develop | ||
env: | ||
GH_TOKEN: ${{ secrets.LEAD_ACCESS_TOKEN }} | ||
send_final_slack_notification: | ||
name: Send Final Slack Notification | ||
needs: [conduct_merge] | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: Send Notification that Develop is up to date | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.INTERNAL_DEV_SLACK_WEBHOOK_URL }} | ||
SLACK_COLOR: ${{ contains(join(needs.*.result, ' '), 'failure') && 'failure' || 'success' }} | ||
SLACK_TITLE: 'Main merged into Develop' | ||
SLACK_FOOTER: '' | ||
MSG_MINIMAL: true | ||
SLACK_MESSAGE_ON_FAILURE: '<!here> New Release has been <${{ github.event.release.html_url }}|published>! FAILED to merge main into Develop.' | ||
SLACK_MESSAGE_ON_SUCCESS: '<!here> New Release has been <${{ github.event.release.html_url }}|published>! Main was SUCCESSFULLY merged into Develop.' | ||
SLACK_MESSAGE: '<!here> New Release has been <${{ github.event.release.html_url }}|published>! Merging main into develop finished with status ${{ job.status }}.' |
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,39 @@ | ||
name: Make Release Branch | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_tag: | ||
description: 'New Release Name' | ||
required: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
MakeNewReleaseBranch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Develop Branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
- name: Create Release Branch and Update Version | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "github_actions_lisa" | ||
RELEASE_TAG=${{ github.event.inputs.release_tag }} | ||
git checkout -b release/${{ github.event.inputs.release_tag }} | ||
echo "$( jq --arg version ${RELEASE_TAG:1} '.version = $version' package.json )" > package.json | ||
sed -E -i '' -e "s/version = \"[0-9\.].+\"/version = \"${RELEASE_TAG:1}\"/g" lisa-sdk/pyproject.toml | ||
echo ${RELEASE_TAG:1} > VERSION | ||
git commit -a -m "Updating version for release ${{ github.event.inputs.release_tag }}" | ||
git push origin release/${{ github.event.inputs.release_tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.LEAD_ACCESS_TOKEN }} | ||
- name: Draft Pull Request | ||
run: | | ||
gh pr create -d --title "Release ${{github.event.inputs.release_tag}} into Main" --body "Release ${{github.event.inputs.release_tag}} PR into Main" --base main --head release/${{ github.event.inputs.release_tag }} | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
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 |
---|---|---|
|
@@ -2,16 +2,30 @@ name: Build and Test | |
|
||
on: | ||
push: | ||
branches: ['main'] | ||
branches: ['main', 'develop', 'release/**', 'hotfix/**'] | ||
pull_request: | ||
branches: ['main'] | ||
branches: ['main', 'develop', 'release/**', 'hotfix/**'] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
send_starting_slack_notification: | ||
name: Send Starting Slack Notification | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send PR Created Notification | ||
if: github.event_name == 'pull_request' && github.event.action == 'opened' | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_TITLE: 'PR Created: ${{ github.event.pull_request.title }} by ${{ github.event.pull_request.user.login }}' | ||
SLACK_FOOTER: '' | ||
MSG_MINIMAL: true | ||
SLACK_MESSAGE: 'PR Created ${{ github.event.pull_request.html_url }}' | ||
cdk-build: | ||
name: CDK Tests | ||
needs: [send_starting_slack_notification] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -27,6 +41,7 @@ jobs: | |
npm run test | ||
pre-commit: | ||
name: Run All Pre-Commit | ||
needs: [send_starting_slack_notification] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -47,3 +62,21 @@ jobs: | |
run: | | ||
npm install | ||
- uses: pre-commit/[email protected] | ||
send_final_slack_notification: | ||
name: Send Final Slack Notification | ||
needs: [cdk-build, pre-commit] | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: Send GitHub Action trigger data to Slack workflow | ||
uses: rtCamp/action-slack-notify@v2 | ||
if: github.event_name != 'pull_request' | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_COLOR: ${{ contains(join(needs.*.result, ' '), 'failure') && 'failure' || 'success' }} | ||
SLACK_TITLE: 'Build Finished' | ||
SLACK_FOOTER: '' | ||
MSG_MINIMAL: 'actions url,commit' | ||
SLACK_MESSAGE_ON_FAILURE: '<!here> Build FAILED on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>' | ||
SLACK_MESSAGE_ON_SUCCESS: 'Build SUCCESS on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>.' | ||
SLACK_MESSAGE: 'Build Finished with status ${{ job.status }} on branch ${{ github.head_ref || github.ref_name }} for <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|commit>' |