Skip to content

trigger-prod-deploy

trigger-prod-deploy #7

name: Deploy to Prod
on:
repository_dispatch:
# Trigger from repository dispatch workflow in promotion/prod branch
types: [trigger-prod-deploy]
env:
OPENSHIFT_NAMESPACE: 6cdc9e-tools
IMAGE_NAME: eagle-public
jobs:
deploy:
name: Deploy to Prod
runs-on: ubuntu-20.04
outputs:
COMMIT_SHA: ${{ steps.read-hash.outputs.SHA }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: "promotion/prod"
- name: Retrieve previous commit hash
id: read-hash
run: echo "::set-output name=SHA::`jq -r '.commit' state.json`"
- name: Log into OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_URL }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
- name: Tag image
run: |
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:prod ${{ env.IMAGE_NAME }}:prod-backup
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:test ${{ env.IMAGE_NAME }}:prod
- name: Notify Rocket.Chat
run: |
curl -X POST -H 'Content-Type: application/json' \
--data '{"alias":"Bot","avatar": "https://github.githubassets.com/images/modules/logos_page/Octocat.png","text":"Commit ${{ steps.read-hash.outputs.SHA }} deployed to ${{ env.IMAGE_NAME }} Prod"}' \
${{ secrets.ROCKET_CHAT_URL }}
sync-main-branch:
name: Rebase Prod
needs: deploy
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: "main"
- run: |
git fetch origin test
git rebase ${{needs.deploy.outputs.COMMIT_SHA}} main
git push origin main