Init projects dashboard #9
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: Build projects-dashboard and maybe Deploy to GitHub Pages | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "projects-dashboard/**" | |
- ".github/workflows/projects-dashboard.yml" | |
pull_request: | |
branches: [main] | |
paths: | |
- "projects-dashboard/**" | |
- ".github/workflows/projects-dashboard.yml" | |
workflow_dispatch: | |
# Allow this job to clone the repo and create a page deployment | |
permissions: | |
contents: write | |
# pages: write | |
# id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout your repository using git | |
uses: actions/checkout@v4 | |
- name: Install, build, and upload your site | |
uses: withastro/action@v3 | |
with: | |
path: ./projects-dashboard | |
node-version: 20 | |
package-manager: pnpm@9 | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
# environment: | |
# name: github-pages | |
# url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout your repository using git | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: github-pages | |
path: projects-dashboard-site | |
- name: Get target folder | |
id: get-target-folder | |
env: | |
GITHUB_HEAD_REF: ${{ github.head_ref }} | |
GITHUB_REF_NAME: ${{ github.ref_name }} | |
run: | | |
ls -R ./projects-dashboard-site | |
cd ./projects-dashboard-site | |
tar -xvf archive.tar . | |
rm archive.tar | |
cd .. | |
ls -R ./projects-dashboard-site | |
if [ "$GITHUB_HEAD_REF" != "" ]; then | |
# This is a pull request | |
BRANCH=$GITHUB_HEAD_REF | |
else | |
# This is a push to a branch | |
BRANCH=$GITHUB_REF_NAME | |
fi | |
if [ "$BRANCH" != "main" ]; then | |
# sanitize branch name | |
BRANCH=$(echo "$BRANCH" | tr '/' '_') | |
echo "path=projects-dashboard-preview-$BRANCH" >> $GITHUB_OUTPUT | |
else | |
echo "path=projects-dashboard" >> $GITHUB_OUTPUT | |
fi | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: projects-dashboard-site | |
target-folder: ${{ steps.get-target-folder.outputs.path }} |