Skip to content

Building and Deploying #15

Building and Deploying

Building and Deploying #15

name: Build and Deploy Binq Static Web
run-name: Building and Deploying
on:
pull_request:
branches:
- "dev"
- "master"
- "!feature-**/"
env:
NODE_VERSION: 20.10.0
ARTIFACT_RETENTION_DAYS: 90
TIMESTAMP: "(date +%Y-%m-%d-%H-%M-%S)"
RUN_NUM: "github.run_number"
jobs:
job_1_build:
name: Build and Upload Production Artifact
runs-on: ubuntu-latest
outputs:
artifact_name: "build_${{ env.TIMESTAMP }}"
steps:
- run: echo "Attempting to install required tools and build project"
- uses: actions/checkout@v4
- name: "Use Node.js ${{ env.NODE_VERSION }}"
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install Dependencies and Build project
run: |
npm ci
npx tailwindcss build -i ./src/input.css -o ./src/output.css --minify
npm run build --f-present
- name: Store production artifacts
uses: actions/upload-artifact@v4
with:
name: "artifact_${{ env.RUN_NUM }}_${{ env.TIMESTAMP }}"
path: |
dist
!dist/**/*.md
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
- run: echo "🍏 Build and save artifact status is ${{ job.status }}."
job_2_deploy:
name: Attempt to Deploy Project
if: github.ref == 'refs/heads/master' && github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- name: Download Latest Artifact
uses: actions/download-artifact@v4
with:
name: "artifact_${{ needs.job_1_build.outputs.artifact_name }}"
- name: Deploy to Azure
run: echo "Deploy to Azure is a success!"