chore(CI): add PR labeler workflow #32
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: | |
push: | |
jobs: | |
test: | |
name: Unit Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21.x | |
- uses: actions/checkout@v3 | |
- run: cd builder && go test -race ./... | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21.x | |
- name: Checkout base branch | |
if: ${{ github.ref != 'refs/heads/photos' }} | |
uses: actions/checkout@v3 | |
- name: Checkout master branch | |
if: ${{ github.ref == 'refs/heads/photos' }} | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
- name: Checkout photos branch | |
uses: actions/checkout@v3 | |
with: | |
ref: photos | |
path: pages/photos | |
- name: Cache assets | |
uses: actions/cache@v3 | |
with: | |
path: .cache | |
key: build-cache-${{ hashFiles('pages/photos/**/*.jpg') }} | |
restore-keys: | | |
build-cache-${{ hashFiles('pages/photos/**/*.jpg') }} | |
build-cache- | |
- name: Build pages | |
run: make build | |
- name: Save artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
lighthouse: | |
name: Lighthouse Test | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: ${{ github.ref != 'refs/heads/photos' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Load artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- uses: treosh/lighthouse-ci-action@v10 | |
with: | |
configPath: .github/lighthouse.json | |
runs: 3 | |
urls: | | |
/ | |
/blog | |
/blog/2020/05/blanktar-renewal | |
/blog/2023/08/golang-goldmark-custom-renderer | |
/works | |
/photos | |
uploadArtifacts: true | |
preview: | |
name: Preview Deploy | |
runs-on: ubuntu-latest | |
needs: [test, build] | |
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/photos' }} | |
environment: | |
name: preview | |
url: ${{ steps.deploy.outputs.url }} | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
- name: Instal Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Load artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Pull Vercel environment information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy to Vercel | |
id: deploy | |
run: | | |
echo -n "url=" >> $GITHUB_OUTPUT | |
vercel deploy --token=${{ secrets.VERCEL_TOKEN }} >> $GITHUB_OUTPUT | |
production: | |
name: Production Deploy | |
runs-on: ubuntu-latest | |
needs: [test, lighthouse, build] | |
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/photos' }} | |
environment: | |
name: production | |
url: ${{ steps.deploy.outputs.url }} | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
- name: Instal Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
- name: Load artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Pull Vercel environment information | |
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy to Vercel | |
id: deploy | |
run: | | |
echo -n "url=" >> $GITHUB_OUTPUT | |
vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --prod >> $GITHUB_OUTPUT |