Merge pull request #39 from tobysmith568/renovate/actions-setup-node-4.x #103
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
- renovate/* | |
pull_request: | |
branches: | |
- main | |
- renovate/* | |
jobs: | |
CI: | |
name: Build and test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org/ | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Run ESLint | |
run: npx eslint . --max-warnings 0 | |
- name: Run Prettier | |
run: npx prettier --check . | |
- name: Run CSpell | |
run: npx cspell **/*.* | |
- name: Run E2E Tests | |
uses: cypress-io/github-action@v4 | |
with: | |
browser: chrome | |
install-command: npm ci | |
build: docker build . -t ci-build-image | |
start: docker run --rm -p 8080:80 ci-build-image | |
wait-on: http://localhost:8080 | |
- uses: fossas/fossa-action@v1.3.1 | |
with: | |
api-key: ${{ secrets.FOSSA_API_KEY }} | |
CD: | |
needs: CI | |
name: Deploy to Cloud Run | |
if: success() && github.ref == 'refs/heads/main' | |
environment: | |
name: Production | |
url: https://tobythe.dev | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GCP | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Set up GCP SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Configure Docker | |
run: gcloud auth configure-docker --quiet | |
- name: Build Docker image | |
run: docker build . -t $IMAGE_NAME | |
- name: Push Docker image | |
run: docker push $IMAGE_NAME | |
- name: Deploy Docker image | |
run: gcloud run deploy ${{ secrets.GCP_APP_NAME }} --image $IMAGE_NAME --region europe-west1 --platform managed |