Skip to content

Merge pull request #3 #60

Merge pull request #3

Merge pull request #3 #60

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
name: Build and Deploy
on:
push:
branches:
- main
# tags: [ "v*.*.*" ]
jobs:
deploy:
env:
# https://github.com/actions/setup-java#cache-segment-restore-timeout
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '4'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Authenticate Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: Set up Gcloud CLI
uses: google-github-actions/setup-gcloud@v2
with:
version: '>= 363.0.0'
- name: Authenticate Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build with Maven
run: mvn -B package -DskipTests
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{vars.DOCKER_CRED_HELPER}} -q
- name: Update VM with new image
run: |
gcloud compute instances update-container ${{vars.VM_NAME}} --zone=${{vars.ZONE}} \
--container-image=${{vars.DOCKER_CRED_HELPER}}/${{vars.IMAGE_PATH}}