Skip to content

Workflow file for this run

name: Build/Push Docker Image and update the service
on:
push:
branches:
- main
- dev
paths:
- 'web-app/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Tag
run: |
if [[ $GITHUB_REF == 'refs/heads/main' ]]; then
echo "TAG=latest" >> $GITHUB_ENV
elif [[ $GITHUB_REF == 'refs/heads/dev' ]]; then
echo "TAG=dev" >> $GITHUB_ENV
fi
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: ./web-app
file: ./web-app/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/web3-testimonials:${{ env.TAG }}
- name: Logout from DockerHub
run: docker logout
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Authenticate with Google
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Deploy to cloud run
id: 'deploy'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
service: 'web3-testimonials'
image: 'jbhv12/web3-testimonials:latest'
- name: 'Use output'
run: 'curl "${{ steps.deploy.outputs.url }}"'