[post] Part 3 - Engineering Portfolio Management #217
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: CI | |
on: | |
workflow_dispatch: | |
inputs: {} | |
pull_request: | |
branches: | |
- main | |
jobs: | |
setup: | |
name: Deploy Setup | |
runs-on: ubuntu-latest | |
outputs: | |
frontend-changed: ${{ steps.changes.outputs.frontend-changed }} | |
data-changed: ${{ steps.changes.outputs.data-changed }} | |
backend-changed: ${{ steps.changes.outputs.backend-changed }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Detect Changes | |
id: changes | |
run: | | |
FRONTEND_DIFF=$(git diff --name-only origin/main -- frontend/* | wc -l | xargs) | |
DATA_DIFF=$(git diff --name-only origin/main -- data/* | wc -l | xargs) | |
BACKEND_DIFF=$(git diff --name-only origin/main -- backend/* | wc -l | xargs) | |
if [[ "$FRONTEND_DIFF" != "0" ]]; then | |
echo "frontend-changed=true" >> $GITHUB_OUTPUT | |
fi | |
if [[ "$DATA_DIFF" != "0" ]]; then | |
echo "data-changed=true" >> $GITHUB_OUTPUT | |
fi | |
if [[ "$BACKEND_DIFF" != "0" ]]; then | |
echo "backend-changed=true" >> $GITHUB_OUTPUT | |
fi | |
build-frontend: | |
name: Build Frontend | |
if: ${{ needs.setup.outputs.frontend-changed == 'true' }} | |
runs-on: ubuntu-latest | |
needs: [setup] | |
steps: | |
- name: Install Task | |
uses: arduino/[email protected] | |
with: | |
version: 3.x | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Node | |
uses: actions/[email protected] | |
with: | |
cache: 'npm' | |
cache-dependency-path: 'frontend/package-lock.json' | |
node-version: '20' | |
- name: Install Dependencies | |
working-directory: frontend | |
run: npm ci | |
- name: Build Frontend | |
run: task build:frontend | |
build-data: | |
name: Build Data | |
if: ${{ needs.setup.outputs.data-changed == 'true' }} | |
runs-on: ubuntu-latest | |
needs: [setup] | |
steps: | |
- name: Install Task | |
uses: arduino/[email protected] | |
with: | |
version: 3.x | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Build data | |
run: task build:data | |
test-backend: | |
name: Deploy & Test Backend | |
if: ${{ needs.setup.outputs.backend-changed == 'true' }} | |
runs-on: ubuntu-latest | |
needs: [setup] | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Node | |
uses: actions/[email protected] | |
with: | |
cache: 'npm' | |
cache-dependency-path: 'backend/package-lock.json' | |
node-version: '20' | |
- name: Install Dependencies | |
working-directory: backend | |
run: npm ci | |
- name: Deploy backend | |
uses: cloudflare/[email protected] | |
with: | |
apiToken: ${{ secrets.CF_API_KEY }} | |
accountId: ${{ secrets.CF_ACCOUNT }} | |
workingDirectory: backend | |
command: deploy --env staging | |
- name: Run Integration Tests | |
uses: grafana/[email protected] | |
env: | |
ENV: staging | |
PSK: ${{ secrets.BLOG_ADMIN_TOKEN }} | |
with: | |
filename: backend/test/script.js |