Skip to content

test-GCP-CI-CD

test-GCP-CI-CD #79

Workflow file for this run

name: test-GCP-CI-CD
on:
push:
branches:
- main
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Testing branch'
permissions:
id-token: write
contents: read
env:
PROJECT_ID: "Ttucktak" # TODO: update Google Cloud project id
REPOSITORY: "wgnwmgm" # TODO: update Artifact Registry repository name
SERVICE: "ttucktak_server" # TODO: update Cloud Run service name
GCE_INSTANCE: ${{ secrets.GCE_INSTANCE }}
GCE_INSTANCE_ZONE: ${{ secrets.GCE_INSTANCE_ZONE}}
jobs:
build-deploy:
# Add 'id-token' with the intended permissions for workload identity federation
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Set Secret yml file.
run: touch ./src/main/resources/secret.yml && echo "${{ secrets.SECRETYML }}" > ./src/main/resources/secret.yml && cat ./src/main/resources/secret.yml
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Build with Gradle
run: ./gradlew build
shell: bash
#- name: Google Auth
#id: auth
#uses: 'google-github-actions/auth@v2'
#with:
#token_format: 'access_token'
#workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' # e.g. - projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider
#service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' # e.g. - [email protected]
# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
id: docker-auth
uses: 'docker/login-action@v1'
with:
username: 'wgnwmgm'
password: '${{ secrets.WGNW_DOCKER_TOKEN }}'
#- name: 'Set up Cloud SDK'
#uses: 'google-github-actions/setup-gcloud@v2'
#with:
#version: '>= 363.0.0'
#- name: 'Use gcloud CLI'
#run: 'gcloud info'
- name: Build and Push Container
run: |-
docker build --platform linux/arm64 -t "${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
# END - Docker auth and build
#- name: Deploy
#run: |-
#gcloud compute instances update-container "$GCE_INSTANCE" \
#--zone "$GCE_INSTANCE_ZONE" \
#--container-image "${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"