Trigger release candidate build and deploy #447
This file contains hidden or 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
name: Trigger release candidate build and deploy | |
on: | |
workflow_run: | |
workflows: | |
- "Push Tests" | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
deploy_to_stage_env_on_test_pass_on_main: | |
runs-on: ubuntu-latest | |
# deployment to staging is only triggered if dependent workflow ("Push Tests") | |
# pass successfully | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
fetch-depth: 0 # fetch all history to make merges work correctly | |
- name: Merge main branch into staging branch | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
echo "Checking out 'staging' branch" | |
git checkout staging | |
echo "Confirming checked out branch receiving merge is: $(git branch --show-current)" | |
echo "Listing locally available branches AFTER 'staging' branch is checked out:" | |
echo "$(git branch --list)" | |
echo "Latest commit on 'staging' branch is: $(git log -1 --format='%H' staging)" | |
echo "Latest commit on 'main' branch is: $(git log -1 --format='%H' main)" | |
echo "About to merge 'main' branch into 'staging' branch" | |
git merge --verbose main -m "Merging main branch into staging branch" | |
git push origin staging | |
- name: Trigger repository_dispatch to build images for staging | |
if: success() | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
event-type: build-images-for-staging | |
client-payload: '{"ref": "refs/heads/staging"}' | |
- name: Send slack notification if main not merged into staging | |
if: failure() | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,commit,author,eventName,workflow,job,mention | |
mention: "here" | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} |