CORE API - Build & Deploy To DEV #328
Workflow file for this run
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
name: CORE API - Build & Deploy To DEV | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
paths: | |
- migrations/** | |
- services/core-api/** | |
- .github/workflows/core-api.build.deploy.dev.yaml | |
env: | |
INITIAL_TAG: latest | |
TAG: dev | |
NAME: backend | |
MIG: flyway | |
CONTEXT: services/core-api/ | |
MIG_CONTEXT: migrations/ | |
jobs: | |
build-backend: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login | |
run: | | |
docker login -u ${{ secrets.CLUSTER_REGISTRY_USER }} -p ${{ secrets.BUILD_TOKEN }} ${{ secrets.CLUSTER_REGISTRY }} | |
- name: Build n Tag | |
run: | | |
docker build -t ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ env.CONTEXT }} -f ${{ env.CONTEXT }}Dockerfile.ci | |
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }}:${{ env.INITIAL_TAG }} | |
docker tag ${{ env.NAME }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }}:${{ env.TAG }} | |
- name: Push | |
run: | | |
docker push --all-tags ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.NAME }} | |
build-flyway: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login | |
run: | | |
docker login -u ${{ secrets.CLUSTER_REGISTRY_USER }} -p ${{ secrets.BUILD_TOKEN }} ${{ secrets.CLUSTER_REGISTRY }} | |
- name: Build n Tag | |
run: | | |
docker build -t ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ env.MIG_CONTEXT }} -f ${{ env.MIG_CONTEXT }}Dockerfile.flyway.ci | |
docker tag ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }}:${{ env.INITIAL_TAG }} | |
docker tag ${{ env.MIG }}:${{ env.INITIAL_TAG }} ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }}:${{ env.TAG }} | |
- name: Push | |
run: | | |
docker push --all-tags ${{ secrets.CLUSTER_REGISTRY }}/${{ secrets.NS_TOOLS }}/${{ env.MIG }} | |
trigger-gitops: | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
needs: [build-backend, build-flyway] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Git Ops Push | |
run: ./gitops/commit.sh core-api dev dev ${{ github.actor }} ${{ secrets.GH_TOKEN }} | |
- name: Install oc | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
oc: "4.7" | |
- uses: clowdhaus/argo-cd-action/@main | |
env: | |
# Only required for first step in job where API is called | |
# All subsequent setps in a job will not re-download the CLI | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
command: version | |
options: --client | |
- uses: clowdhaus/argo-cd-action/@main | |
# CLI has already been downloaded in prior step, no call to GitHub API | |
with: | |
command: version | |
options: --client | |
- name: Setup ArgoCD CLI | |
if: ${{ env.NEEDS_ROLLOUT=='true' }} | |
uses: clowdhaus/argo-cd-action/@main | |
with: | |
version: 2.6.7 | |
command: version | |
options: --client | |
- name: oc login | |
run: oc login --token=${{ secrets.BUILD_TOKEN }} --server=${{ secrets.CLUSTER_API }} | |
- name: argocd login | |
run: argocd login --auth-token=${{ secrets.ARGO_CD_CLI_JWT }} --server=${{ secrets.ARGOCD_SERVER }} --grpc-web | |
- name: Notification | |
run: ./gitops/watch-deployment.sh core-api dev ${{ github.sha }} ${{ secrets.DISCORD_DEPLOYMENT_WEBHOOK }} | |
run-if-failed: | |
runs-on: ubuntu-20.04 | |
needs: [trigger-gitops] | |
if: always() && (needs.trigger-gitops.result == 'failure') | |
steps: | |
- name: Notification | |
run: ./gitops/watch-deployment.sh core-api dev ${{ github.sha }} ${{ secrets.DISCORD_DEPLOYMENT_WEBHOOK }} 1 |