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
# Workflow for deploying from main branch to /hanabi-tracker | |
name: Build for GitHub Pages (Release) | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages-production" | |
cancel-in-progress: true | |
jobs: | |
deploy: | |
environment: | |
name: github-pages | |
url: "https://jparkhouse.github.io/hanabi-tracker" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Install Dependencies | |
run: npm install | |
- name: Build | |
run: npm run build -- --mode release | |
- name: Debug - List Dist Contents | |
run: ls -l dist | |
- name: Save Build Output | |
run: mv dist ../dist-production | |
- name: Discard Local Changes | |
run: git reset --hard && rm -rf | |
- name: Checkout gh-pages Branch | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git fetch origin | |
git checkout gh-pages || git checkout --orphan gh-pages | |
- name: Restore Build Output | |
run: # Move the test directory temporarily, clear, insert build, insert test | |
mv ./test ../test && rm -rf ./* && cp -r ../dist-production/* . && mkdir ./test && mv ../test/* ./test/ | |
- name: Commit and Push Changes | |
# checks if there are changes, so that no changes does not result in a falsely failing build | |
run: | | |
if ! git diff --quiet FETCH_HEAD; then | |
git add . | |
git commit -m 'Deploy to GitHub Pages from main branch' | |
git push origin gh-pages | |
else | |
echo "No changes to commit" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |