Skip to content

Added conditional check to run ECR push action when the Docker Hub pu… #190

Added conditional check to run ECR push action when the Docker Hub pu…

Added conditional check to run ECR push action when the Docker Hub pu… #190

Workflow file for this run

name: Push
on:
push:
branches:
- main
paths:
- 'dea_conflux/**'
- 'examples/**'
- '.github/workflows/push.yml'
- 'Dockerfile'
release:
types: [published, edited]
env:
IMAGE_NAME: geoscienceaustralia/dea-conflux
jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get tag for this build if it exists
if: github.event_name == 'release'
run: |
echo "RELEASE=${GITHUB_REF/refs\/tags\/}" >> $GITHUB_ENV
- name: Build and Push semver tagged Docker Image for Release
uses: whoan/docker-build-with-cache-action@v4
if: github.event_name == 'release'
with:
image_name: ${{ env.IMAGE_NAME }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
image_tag: ${{ env.RELEASE }}
- name: Get git commit hash for push to main
if: github.event_name != 'release'
run: |
git fetch --all --tags
echo "RELEASE=$(git describe --tags)" >> $GITHUB_ENV
- name: Build and Push unstable Docker Image for push to main
uses: whoan/docker-build-with-cache-action@v4
if: github.event_name != 'release'
with:
image_name: ${{ env.IMAGE_NAME }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
image_tag: latest,${{ env.RELEASE }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
if: github.event_name != 'release'
with:
role-to-assume: arn:aws:iam::538673716275:role/dea-conflux_github-actions-role
aws-region: ap-southeast-2
- name: Push image to ECR
uses: whoan/docker-build-with-cache-action@master
if: github.event_name != 'release'
with:
context: ./docker
registry: 538673716275.dkr.ecr.ap-southeast-2.amazonaws.com
image_name: ${{ env.IMAGE_NAME }}
image_tag: latest,${{ env.RELEASE }}
build_extra_args: '{"--build-arg": "UPDATE_VERSION=${{ env.RELEASE }}"}'