Skip to content

Publish GitHub pages #10

Publish GitHub pages

Publish GitHub pages #10

Workflow file for this run

run-name: Publish GitHub pages
name: publish-pages
on:
push:
paths: [ "**" ]
pull_request:
jobs:
# Single deploy job since we're just deploying
gen-pages:
name: Generate pages
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Get image name
env:
EVENT_NAME: ${{ github.event_name }}
PUSH_REPO_NAME: ${{ github.repository }}
PR_REPO_NAME: ${{ github.event.repository.full_name }}
IMAGE_SUFFIX: gen-pages:latest
shell: bash
run: |
result=""
case "$EVENT_NAME" in
push)
result="$PUSH_REPO_NAME"
;;
pull_request)
result="$PR_REPO_NAME"
;;
esac
result=$(echo "$result/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]')
echo "IMAGE=$result" >> $GITHUB_ENV
- name: Checkout Melee repository
uses: actions/checkout@v3
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull generator image
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE }}
- name: Generate pages
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
--volume /tmp/output:/output \
${{ env.REGISTRY }}/${{ env.IMAGE }}
- name: Upload generated pages
uses: actions/upload-artifact@v3
with:
name: pages
path: /tmp/output
deploy-pages:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: gen-pages
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
concurrency:
group: "pages"
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download generated pages
uses: actions/download-artifact@v3
with:
name: pages
path: /tmp/output
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v1.0.7
with:
path: /tmp/output
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1.2.4