Skip to content

Merge branch 'main' into deployment #8

Merge branch 'main' into deployment

Merge branch 'main' into deployment #8

Workflow file for this run

name: Build and Deploy
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Cache Docker image
uses: actions/cache@v3
with:
path: /tmp/myimage.tar
key: mbon-meta-image-${{ github.sha }}
restore-keys: |
mbon-meta-image-
- name: Login to Docker Hub
uses: docker/[email protected]
continue-on-error: true
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build MBON Metadata Form image
uses: docker/[email protected]
with:
context: ./metadata_form
push: false
tags: gmri/mbon-metadata-form:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/myimage.tar
deploy:
name: Build and Push tagged image to Docker Hub, and update Argo config
runs-on: ubuntu-22.04
needs: build
if: |
github.repository == 'neracoos-open/MBON_DMAC'
&& github.ref == 'refs/heads/main'
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: Cache Docker image
uses: actions/cache@v3
with:
path: /tmp/myimage.tar
key: mbon-meta-image-${{ github.sha }}
restore-keys: |
mbon-meta-image-
- name: Load Docker image
run: |
docker load --input /tmp/myimage.tar
docker image ls -a
- name: "Login to Docker Hub"
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Tag Docker image
run: docker tag gmri/mbon-metadata-form gmri/mbon-metadata-form:${{ steps.vars.outputs.sha_short }}
- name: Push Docker image
run: docker push gmri/mbon-metadata-form:${{ steps.vars.outputs.sha_short }}
- name: Make GitOps directory
run: mkdir gitops
- name: Clone GitOps config repo
run: git clone "https://[email protected]/gulfofmaine/neracoos-aws-cd.git"
working-directory: ./gitops
env:
GITOPS_TOKEN: ${{ secrets.GITOPS_TOKEN }}
- name: Update GitOps config repo
working-directory: ./gitops/neracoos-aws-cd
run: |
sed -i 's/?ref=.\+/?ref=${{ steps.vars.outputs.sha_short }}/' overlays/mbon-metadata/kustomization.yaml
sed -i 's/newTag: .\+/newTag: ${{ steps.vars.outputs.sha_short }}/' overlays/mbon-metadata/kustomization.yaml
git config --global user.email '[email protected]'
git config --global user.name 'NERACOOS MBON Metadata Form CI'
git diff --exit-code && echo 'Already Deployed' || (git commit -am 'Upgrade MBON Metadata Form to ${{ steps.vars.outputs.sha_short }}' && git push)