Update dea-intertidal-image.yml #31
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: DEA Intertidal Image Push | |
env: | |
IMAGE_NAME: geoscienceaustralia/dea-intertidal | |
on: | |
push: | |
branches: | |
- main | |
- tests | |
paths: | |
- 'intertidal/**' | |
- 'data/**' | |
- '.github/workflows/dea-intertidal-image.yml' | |
- 'Dockerfile' | |
- 'requirements.in' | |
- 'setup.py' | |
release: | |
types: [created, edited, published] | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Build DEA Intertidal image | |
timeout-minutes: 20 | |
shell: bash | |
run: | | |
docker-compose build | |
- name: Run dockerized integration tests and copy outputs | |
run: | | |
# Set up artifacts directory to house outputs from integration tests, | |
# giving all users read and write permissions | |
mkdir artifacts | |
chmod a+rw artifacts | |
# Run integration tests using Docker | |
docker-compose up -d | |
docker-compose exec -T dea_intertidal /bin/sh -c "sh ./tests/run_tests" | |
docker-compose down | |
push_ecr: | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: arn:aws:iam::538673716275:role/github-actions-role | |
aws-region: ap-southeast-2 | |
- name: Get tag for this build if it exists | |
if: github.event_name == 'release' | |
run: | | |
echo "RELEASE=${GITHUB_REF/refs\/tags\/}" >> $GITHUB_ENV | |
- name: Push release image to ECR | |
uses: whoan/docker-build-with-cache-action@master | |
if: github.event_name == 'release' | |
with: | |
registry: 538673716275.dkr.ecr.ap-southeast-2.amazonaws.com | |
image_name: ${{ env.IMAGE_NAME }} | |
image_tag: ${{ env.RELEASE }} | |
- name: Get git commit hash for push to main | |
if: github.event_name != 'release' | |
run: | | |
echo "TAG=dev$(git rev-parse --short HEAD)" \ | |
>> $GITHUB_ENV | |
- name: Push unstable image to ECR | |
uses: whoan/docker-build-with-cache-action@master | |
if: github.event_name != 'release' | |
with: | |
registry: 538673716275.dkr.ecr.ap-southeast-2.amazonaws.com | |
image_name: ${{ env.IMAGE_NAME }} | |
image_tag: latest,${{ env.TAG }} |