Add image build workflow

This commit is contained in:
Ali Ghanbarzadeh 2023-04-21 13:06:54 +02:00
parent 6e71aaa44c
commit e94e23e589
2 changed files with 35 additions and 0 deletions

11
.github/workflows/.docker/Dockerfile vendored Normal file
View file

@ -0,0 +1,11 @@
FROM eclipse-temurin:17-jdk-jammy
WORKDIR /app
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
RUN ./mvnw dependency:resolve
COPY src ./src
CMD ["./mvnw", "spring-boot:run"]

24
.github/workflows/container-build.yaml vendored Normal file
View file

@ -0,0 +1,24 @@
name: Push to GCR GitHub Action
on: [push]
jobs:
build-and-push-to-gcr:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v3
- name: 'Authenticate to Google Cloud'
id: auth
uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/871215665939/locations/global/workloadIdentityPools/github/providers/github'
service_account: push-to-gcr@github-actions-gcp.iam.gserviceaccount.com
- uses: RafikFarhad/push-to-gcr-github-action@v5-beta
with:
registry: gcr.io
project_id: github-actions-gcp
image_name: spring-petclinic-test
image_tag: latest,v1
dockerfile: ./docker/Dockerfile
context: ./docker