Deploy to Staging #31
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 | |
run-name: Deploy to ${{ inputs.deploy-environment || 'Staging' }} | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy-environment: | |
description: 'Which environment to deploy to' | |
required: true | |
type: choice | |
options: | |
- Staging | |
- Production | |
default: Staging | |
push: | |
branches: | |
- 'main' | |
- 'gha-deploy-*' | |
jobs: | |
queue: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
concurrent_skipping: 'outdated_runs' | |
cancel_others: true | |
skip_after_successful_duplicate: true | |
paths_ignore: '["**/README.md", "**/docs/**"]' | |
do_not_skip: '["workflow_dispatch", "schedule"]' | |
verify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cloning repository | |
uses: actions/checkout@v4 | |
- name: Setting up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Installing Node.js packages | |
run: npm ci | |
- name: Running tests | |
run: | | |
npx gulp updateTestResources | |
npx gulp lintNode | |
npx gulp lintYaml | |
npm run test:platform | |
npm run test:playground | |
prepare: | |
needs: verify | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cloning repository | |
uses: actions/checkout@v4 | |
- name: Setting up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Installing Node.js packages | |
run: npm ci | |
- name: Preparing build | |
env: | |
APP_ENV: production | |
AMP_DOC_TOKEN: ${{ secrets.AMP_DOC_TOKEN }} | |
run: | | |
npx gulp buildPrepare | |
- name: Storing build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-setup | |
path: artifacts/setup.tar.gz | |
build: | |
env: | |
APP_ENV: production | |
needs: prepare | |
strategy: | |
matrix: | |
language: | |
[ | |
'en', | |
'de', | |
'fr', | |
'ar', | |
'es', | |
'it', | |
'id', | |
'ja', | |
'ko', | |
'pt_BR', | |
'ru', | |
'tr', | |
'zh_CN', | |
'pl', | |
'vi', | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cloning repository | |
uses: actions/checkout@v4 | |
- name: Setting up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Installing Node.js packages | |
run: npm ci | |
- name: Setting up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Installing Grow | |
run: | | |
sudo apt-get install libyaml-dev | |
pip install grow --upgrade-strategy eager | |
- name: Fetching build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-setup | |
path: artifacts | |
- name: Unpacking artifacts | |
run: | | |
npx gulp unpackArtifacts | |
- name: Building pages | |
run: | | |
npx gulp buildPages --locales ${{ matrix.language }} | |
- name: Storing build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pages-${{ github.run_id }}-${{ matrix.language }} | |
path: artifacts | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: Production | |
env: | |
APP_ENV: production | |
NETLIFY_DEPLOY_TOKEN: ${{ secrets.NETLIFY_DEPLOY_TOKEN }} | |
steps: | |
- name: Cloning repository | |
uses: actions/checkout@v4 | |
- name: Setting up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
cache: npm | |
- name: Installing Node.js packages | |
run: npm ci | |
- name: Fetching build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Unpacking artifacts | |
run: | | |
npx gulp unpackArtifacts | |
- name: Finalizing build | |
run: | | |
npx gulp buildFinalize | |
- name: Deploying | |
env: | |
DEPLOY_ENVIRONMENT: ${{ inputs.deploy-environment || 'Staging' }} | |
run: | | |
npx gulp staticDeploy |