Skip to content

feat(config): implement commitlint + husky with controlled github act… #63

feat(config): implement commitlint + husky with controlled github act…

feat(config): implement commitlint + husky with controlled github act… #63

name: Deploy Angular Blog to Cloud Run
on:
push:
branches:
- main
jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commit message
id: check
run: |
message=$(git log --format=%B -n 1 ${{ github.sha }})
echo "Checking commit: ${{ github.sha }}"
echo "Message: $message"
should_run=false
if echo "$message" | grep -E "^[^(]+\((web|config)\):" > /dev/null; then
should_run=true
fi
echo "should-run=$should_run" >> $GITHUB_OUTPUT
echo "Web workflow should run: $should_run"
test:
runs-on: ubuntu-latest
needs: check-commit
if: needs.check-commit.outputs.should-run == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- run: npm ci
- uses: browser-actions/setup-chrome@v1
- name: Use Chrome with no-sandbox
run: |
printf '#!/usr/bin/env bash\nexec "%s" --no-sandbox --disable-setuid-sandbox "$@"\n' "$(which chrome)" > /tmp/chrome-nosandbox.sh
chmod +x /tmp/chrome-nosandbox.sh
echo "CHROME_BIN=/tmp/chrome-nosandbox.sh" >> $GITHUB_ENV
- run: sudo mount -t tmpfs tmpfs /dev/shm -o size=2G
- run: xvfb-run -a npm run test -- --browsers=ChromeHeadless --watch=false --no-progress
deploy:
runs-on: ubuntu-latest
needs: test
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Configure Docker for GCR
run: gcloud auth configure-docker
- name: Build and Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
service: angular-blog
region: europe-west4
source: .
flags: '--verbosity=debug --timeout=1200'
env_vars: |
NODE_ENV=production