Merge pull request #385 from P4-Games/develop #252
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy to Cloud Run | |
on: | |
push: | |
branches: [ main, feature/version-auto ] | |
env: | |
PROJECT_ID: number-one-fan | |
REGION: us-central1 | |
SERVICE: nof-landing # cloud run service name | |
IMAGE_NAME: nof-landing | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Google Auth | |
id: 'auth' | |
uses: 'google-github-actions/auth@v0' | |
with: | |
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v0' | |
- name: Set NOF_VERSION in environment | |
id: env-nof-version | |
run: | | |
bash ./scripts/product_version.sh -v patch | |
- name: Build Docker Image | |
run: docker build -t ${{ env.IMAGE_NAME }}:latest . | |
- name: Automatic Tagging of Releases | |
id: increment-git-tag | |
run: | | |
bash ./scripts/git_update.sh -v patch | |
# the above can be changed to major, minor or patch (e.g 2.1.3 respectively) | |
- name: Configure Docker Client | |
run: |- | |
gcloud auth configure-docker --quiet | |
- name: Push Docker Image to Google Cloud Container Registry (GCR) | |
env: | |
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }} | |
run: |- | |
docker tag ${{ env.IMAGE_NAME }}:latest gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest | |
docker tag ${{ env.IMAGE_NAME }}:latest gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:$GIT_TAG | |
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest | |
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:$GIT_TAG | |
- name: Deploy to Cloud Run | |
id: deploy | |
uses: google-github-actions/deploy-cloudrun@v0 | |
with: | |
service: ${{ env.SERVICE }} | |
region: ${{ env.REGION }} | |
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest |