Skip to content

Update main.yml

Update main.yml #260

Workflow file for this run

name: Docker Image CI for GHCR
on:
push:
tags:
- "*"
jobs:
build_and_push_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build and Push Test Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects-test.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects-test.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles-test.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }}
docker push ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }}
docker tag ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }} ghcr.io/dbca-wa/science-projects-client:test
docker push ghcr.io/dbca-wa/science-projects-client:test
build_and_push_migration:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build and Push Migration Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects-migrated.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects-migrated.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles-migrated.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:migration
docker push ghcr.io/dbca-wa/science-projects-client:migration
build_production:
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build Production Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:${{ steps.tag.outputs.TAG_NAME }}
- name: Save Docker Image as Artifact
uses: actions/upload-artifact@v3
with:
name: production-image
path: |
$(docker save ghcr.io/dbca-wa/science-projects-client:${{ steps.tag.outputs.TAG_NAME }} | tee /tmp/production-image.tar)
push_production:
needs: build_production
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Download Docker Image Artifact
uses: actions/download-artifact@v3
with:
name: production-image
- name: Load Docker Image
run: |
docker load -i production-image.tar
- name: Push Production Image
env:
TAG_NAME: ${{ needs.build_production.outputs.TAG_NAME }}
run: |
echo "Pushing image with tag: $TAG_NAME"
docker push ghcr.io/dbca-wa/science-projects-client:${TAG_NAME}
docker tag ghcr.io/dbca-wa/science-projects-client:${TAG_NAME} ghcr.io/dbca-wa/science-projects-client:latest
docker push ghcr.io/dbca-wa/science-projects-client:latest