Skip to content

(abandoned) temporary workflow change #29

(abandoned) temporary workflow change

(abandoned) temporary workflow change #29

Workflow file for this run

name: CICD
on:
push:
branches:
- '*'
pull_request:
types:
- opened
- closed
env:
SERVICE: gore
PROJECT_ID: ${{ secrets.PROJECT_ID }}
REGION: us-central1
jobs:
cicd:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if PR was merged
run: |
if [ "${{ github.event.pull_request.merged }}" == "true" ]; then
echo "PR was merged."
else
echo "PR was closed without merging."
exit 0
fi
- name: Make envfile
uses: SpicyPizza/create-envfile@v2.0
with:
file_name: .env
envkey_INSTANCE_CONNECTION_NAME: ${{ secrets.INSTANCE_CONNECTION_NAME }}
envkey_DB_USER: ${{ secrets.DB_USER }}
envkey_DB_NAME: ${{ secrets.DB_NAME }}
envkey_DB_PASS: ${{ secrets.DB_PASS }}
envkey_GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
envkey_BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
envkey_LOCAL_LOG: "FALSE"
envkey_CLOUD_LOG: "TRUE" # only cloud logging is needed for the deployed app
envkey_LOG_NAME: ${{ secrets.LOG_NAME }}
envkey_PROJECT_ID: ${{ env.PROJECT_ID }}
envkey_YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
envkey_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
envkey_API_AUTH_TOKEN: ${{ secrets.API_AUTH_TOKEN }}
- name: Create credentials json file
uses: jsdaniell/create-json@v1.2.2
with:
name: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}
export_default_credentials: true
- name: Build Docker image
run: docker build -t gore .
- name: Tag Docker image for Docker Hub
run: docker tag gore ${{ secrets.DOCKER_USERNAME }}/gore:latest
# it is a private image on docker hub, hosted there just for my own reference
- name: Push Docker image to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} && docker push ${{ secrets.DOCKER_USERNAME }}/gore:latest
- name: Tag Docker image for GCR
run: docker tag gore gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:latest
- name: Push Docker image to Google Container Registry (GCR)
run: |
gcloud auth configure-docker
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:latest
- name: Deploy to Cloud Run
id: deploy
run: |
gcloud run deploy ${{ env.SERVICE }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:latest \
--region ${{ env.REGION }} \
--platform managed