v1.30.0 #12
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 Production Workflow | |
on: | |
release: | |
types: [created] | |
jobs: | |
upload-to-docker-hub: | |
name: Upload image with tag version to Docker Hub 🐳 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout GitHub repository 📡 | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Log in to Docker Hub 🔐 | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push Docker image on tag name 🐳 | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: antoinezanardi/werewolves-assistant-api:${{ github.event.release.tag_name }} | |
- name: Build and push Docker image on latest 🐳 | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: antoinezanardi/werewolves-assistant-api:latest | |
deploy: | |
name: Deploy to production 🚀 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup GitHub repository 🔧 | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Install pnpm 🏗️ | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
run_install: false | |
- name: Setup NodeJS ✨ | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'pnpm' | |
- name: Restore pnpm dependencies from cache 🥡 | |
uses: actions/cache/restore@v4 | |
id: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-pnpm-v3-${{ hashFiles('pnpm-lock.yaml') }} | |
- name: Write production .env file 📝 | |
run: | | |
npx rimraf env/.env.production | |
echo ENVIRONMENT="production" >> env/.env.production | |
echo DATABASE_HOST="${{ secrets.PRODUCTION_DATABASE_HOST }}" >> env/.env.production | |
echo DATABASE_NAME="${{ secrets.PRODUCTION_DATABASE_NAME }}" >> env/.env.production | |
echo DATABASE_USERNAME="${{ secrets.PRODUCTION_DATABASE_USERNAME }}" >> env/.env.production | |
echo DATABASE_PASSWORD="${{ secrets.PRODUCTION_DATABASE_PASSWORD }}" >> env/.env.production | |
echo CORS_ORIGIN="${{ secrets.PRODUCTION_CORS_ORIGIN }}" >> env/.env.production | |
cat env/.env.production | |
- name: Build app ✨ | |
run: pnpm run build | |
- name: Auth to GCP ☁️ | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: ${{ secrets.PRODUCTION_GCP_SA_KEY }} | |
- name: Transform and format version for GCP ♻️ | |
id: format-version-for-gcp | |
run: | | |
version=${{ github.event.release.tag_name }} | |
version=${version//./-} | |
echo "FORMATTED_VERSION_FOR_GCP=${version}" >> $GITHUB_OUTPUT | |
- name: Deploy to production 🚀 | |
uses: 'google-github-actions/deploy-appengine@v2' | |
with: | |
project_id: ${{ secrets.PRODUCTION_GCP_PROJECT_ID }} | |
flags: "--version=${{ steps.format-version-for-gcp.outputs.FORMATTED_VERSION_FOR_GCP }}" |