Merge pull request #29 from Firgrep/refactor/ci #31
Workflow file for this run
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: Deploy to DEV | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- dev | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
SERVICE: ${{ secrets.SERVICE }} | |
REGION: ${{ secrets.REGION }} | |
TAG: latest | |
jobs: | |
build_and_deploy: | |
if: github.repository_owner == 'systemphil' | |
environment: dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if running in the parent repository | |
run: | | |
if [ "${GITHUB_REPOSITORY}" != "systemphil/sphil" ]; then | |
echo "This workflow is only intended for the parent repository. Skipping deployment." | |
exit 1 | |
fi | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Auth | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | |
- name: Docker Auth | |
id: docker-auth | |
uses: "docker/login-action@v1" | |
with: | |
username: _json_key | |
password: "${{ secrets.GOOGLE_CREDENTIALS }}" | |
registry: "${{ env.REGION }}-docker.pkg.dev" | |
- name: Build and Push Container | |
run: |- | |
docker build \ | |
-f Dockerfile \ | |
-t "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" ./ | |
docker push "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy ${{env.SERVICE}} \ | |
--platform=managed \ | |
--region=${{ env.REGION }} \ | |
--allow-unauthenticated \ | |
--max-instances=4 \ | |
--min-instances=1 \ | |
--update-secrets=NEXT_PUBLIC_SITE_ROOT=NEXT_PUBLIC_SITE_ROOT:latest,NEXT_PUBLIC_GA_ID=NEXT_PUBLIC_GA_ID:latest \ | |
--image="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ env.TAG }}" |