Skip to content

v6.7.0-SNAPSHOT

v6.7.0-SNAPSHOT #453

Workflow file for this run

# This creates docker image for the most recent commit to the repository
# The docker image is intended for development purposes
#
name: build-dev
on:
push
env:
# Auscope-Portal-API docker image name
IMAGE_NAME: auscope-portal-api
permissions:
id-token: write
contents: read
packages: write
jobs:
# Push image to GitHub Packages.
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.17
uses: actions/setup-java@v1
with:
java-version: 1.17
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: set application.yaml to default
run: |
mv ./src/main/resources/application.yaml.default ./src/main/resources/application.yaml
- name: Set Release version env variable
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV"
echo "WAR_FILE_NAME=target/auscope-portal-api-$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout).war" >> "$GITHUB_ENV"
- name: Build with Maven
run: |
mvn -B clean package spring-boot:build-image --file pom.xml
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to repository only if its the master branch
if: github.ref == 'refs/heads/master'
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=${{ env.RELEASE_VERSION }}
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag auscope-portal-api:$VERSION $IMAGE_ID:$VERSION
docker tag auscope-portal-api:$VERSION $IMAGE_ID:latest
docker push --all-tags $IMAGE_ID
- name: Upload war file artifact
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: auscope-portal-api war file
path: ${{ env.WAR_FILE_NAME }}
- name: Azure Login
if: github.ref == 'refs/heads/master'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Azure CLI script
if: github.ref == 'refs/heads/master'
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
revname=$(az containerapp revision list -n ${{ secrets.AZURE_DEVCONTAINERNAME }} -g ${{ secrets.AZURE_DEVRG }} --query "[].name" --output tsv)
az containerapp revision restart --revision $revname -g ${{ secrets.AZURE_DEVRG }}