Concert: Doechii in Amsterdam #358
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: Integrate | |
# Run workflow when commits are pushed to pull requests or main branch | |
on: | |
pull_request: null | |
push: | |
branches: | |
- main | |
jobs: | |
# This job generates a new preview build of the website and makes it available to other jobs in the workflow. | |
build_preview: | |
name: Build preview assets | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Restore node_modules folder | |
id: cache-node | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-v2-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-v2 | |
- name: Install frontend dependencies | |
if: steps.cache-node.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Restore Composer dependencies | |
id: cache-php | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
# If no Composer cache exists, install Composer dependencies | |
- name: Install Composer dependencies | |
if: steps.cache-php.outputs.cache-hit != 'true' | |
run: composer install --no-dev --ignore-platform-reqs | |
- name: Create preview build of CSS and JS | |
run: npm run prod | |
- name: Create new preview build of website | |
run: ./vendor/bin/jigsaw build preview | |
env: | |
PREVIEW_URL: https://preview-${{ github.event.number }}.website.sven.luijten.dev | |
- name: Create zip file of preview build | |
run: zip -r build.zip build_preview/ | |
- name: Keep ZIP file as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build_${{ github.event.number }}_zip | |
path: build.zip | |
retention-days: 1 | |
# This job will deploy the website to a preview domain. | |
deploy_preview: | |
name: Deploy to preview | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' | |
# The job is only run, when the `build`-job is finished. | |
needs: | |
- build_preview | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build_${{ github.event.number }}_zip | |
path: ./build | |
- name: Unzip preview build | |
run: unzip ./build/build.zip -d ./build | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Restore node_modules folder | |
id: cache-node | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-v2-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-v2 | |
- name: Install frontend dependencies | |
if: steps.cache-node.outputs.cache-hit != 'true' | |
run: npm ci | |
# Start tracking the deployment status using GitHub deployments | |
- name: Start deployment | |
uses: bobheadxi/deployments@v1 | |
id: deployment_pr | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: 'Pull Request #${{ github.event.number }} Preview' | |
# `head_ref` has to be used here, as otherwhise the deployments | |
# are not shown near the status overview inside a pull request. | |
ref: ${{ github.head_ref }} | |
# Deploy website as a preview to Vercel. | |
- name: Deploy to Vercel | |
uses: amondnet/vercel-action@v25 | |
id: vercel_action_pr | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
# Disable GitHub comments. I don't need a comment telling me that a deployment is happening. | |
github-comment: false | |
# This is not a typo. This structure is created by unzipping the build artifact. | |
working-directory: ./build/build_preview | |
scope: team-svenluijten | |
alias-domains: | | |
preview-{{PR_NUMBER}}.website.sven.luijten.dev | |
# Set the deployment status in GitHub to finished. | |
- name: Update Deployment Status | |
uses: bobheadxi/deployments@v1 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
# We use the deployment ID of a previous step here | |
deployment_id: ${{ steps.deployment_pr.outputs.deployment_id }} | |
# We pass Vercel's own preview URL to the environment. This | |
# way we can easily visit the deployed site from the pull | |
# request. | |
env_url: ${{ steps.vercel_action_pr.outputs.preview-url }} | |
env: 'Pull Request #${{ github.event.number }} Preview' | |
- name: Delete build artifact | |
uses: geekyeggo/delete-artifact@v5 | |
if: always() | |
with: | |
name: build_${{ github.event.number }}_zip | |
# This job generates a new production build of the website and makes it available to other jobs in the workflow. | |
build_production: | |
name: Build production assets | |
runs-on: ubuntu-latest | |
if: github.event.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Restore node_modules folder | |
id: cache-node | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-v2-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-v2 | |
- name: Install frontend dependencies | |
if: steps.cache-node.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Restore Composer dependencies | |
id: cache-php | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
# If no Composer cache exists, install Composer dependencies | |
- name: Install Composer dependencies | |
if: steps.cache-php.outputs.cache-hit != 'true' | |
run: composer install --no-dev --ignore-platform-reqs | |
- name: Create production build of CSS and JS | |
run: npm run prod | |
- name: Create new production build of website | |
run: ./vendor/bin/jigsaw build production | |
- name: Create ZIP file of production build | |
run: zip -r build.zip build_production/ | |
- name: Keep ZIP file as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build_zip | |
path: build.zip | |
retention-days: 1 | |
# This job will deploy the website to production. | |
deploy_production: | |
name: Deploy to production | |
runs-on: ubuntu-latest | |
if: github.event.ref == 'refs/heads/main' | |
# The job is only run, when the `build`-job is finished. | |
needs: | |
- build_production | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build_zip | |
path: ./build | |
- name: Unzip production build | |
run: unzip ./build/build.zip -d ./build | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Restore node_modules folder | |
id: cache-node | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-v2-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-v2 | |
- name: Install frontend dependencies | |
if: steps.cache-node.outputs.cache-hit != 'true' | |
run: npm ci | |
# Start tracking the deployment status using GitHub deployments. | |
# Instead of using a dynamic environment name, we use production | |
- name: Start Deployment | |
uses: bobheadxi/deployments@v1 | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: Production | |
# Deploy website for production to Vercel. | |
- name: Deploy to Vercel | |
uses: amondnet/vercel-action@v25 | |
id: vercel-action | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
github-comment: false | |
working-directory: ./build/build_production | |
scope: team-svenluijten | |
# This argument tells the Vercel Action to mark the deployment for production. | |
vercel-args: '--prod' | |
# Set the deployment status in GitHub to finished. | |
- name: Update Deployment Status | |
uses: bobheadxi/deployments@v1 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env_url: ${{ steps.vercel-action.outputs.preview-url }} | |
env: production | |
- name: Delete production build artifact | |
uses: geekyeggo/delete-artifact@v5 | |
if: always() | |
with: | |
name: build_zip |