Skip to content

Deploy GitHub Pages #64

Deploy GitHub Pages

Deploy GitHub Pages #64

Workflow file for this run

name: "Deploy GitHub Pages"
run-name: "Deploy GitHub Pages"
on:
workflow_dispatch:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
env:
GH_TOKEN: ${{ github.token }}
jobs:
build:
uses: ./.github/workflows/build.yml
deploy:
if: github.ref_name == 'main'
needs: build
runs-on: ubuntu-latest
concurrency:
group: "pages"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: configure-pages
name: "Setup Pages"
uses: actions/configure-pages@v3
- name: "Unarchive Pages Artifact"
uses: actions/[email protected]
with:
name: pages
- name: "Generate a security.txt file"
run: |
tee security.txt << EOF
Contact: ${{ steps.configure-pages.outputs.base_url }}/contact
Policy: ${{ steps.configure-pages.outputs.base_url }}/security/policy
Acknowledgments: ${{ steps.configure-pages.outputs.base_url }}/humans.txt
Canonical: ${{ steps.configure-pages.outputs.base_url }}/security.txt
Expires: $(date -u +"%Y-12-31T23:59:59.999Z")
EOF
- name: "Generate a humans.txt file"
run: gh api "${ENDPOINT}" --template "${TEMPLATE}" | sh | tee humans.txt
env:
ENDPOINT: '/orgs/${{ github.repository_owner }}/repos'
TEMPLATE: |
echo "# Contributors by Repository"
echo
echo "A huge thanks to all and colaborators who have contributed on GitHub!"
echo
{{range .}}
echo "## {{.full_name}}"
echo
gh api '/repos/{{.full_name}}/contributors' --jq '.[].login' | sort -u | xargs -ILOGIN gh api '/users/LOGIN' --jq '"- @" + .login + " (" + (.name // .login) + ")"'
echo
{{end}}
- name: "Generate a robots.txt file"
run: |
tee robots.txt << EOF
Sitemap: ${{ steps.configure-pages.outputs.base_url }}/sitemap.txt
EOF
- name: "Generate a version.txt file"
run: |
tee version.txt << EOF
Deployed: $(date --universal +'%FT%TZ')
Version: v0.0.${{ github.run_number }}.$((${{ github.run_attempt }} - 1))
Source: ${{github.server_url }}/${{ github.repository }}/tree/$(echo "${{ github.sha }}" | head -c 7)
EOF
- name: "Generate a sitemap.txt file"
env: { BASE_URL: '${{ steps.configure-pages.outputs.base_url }}' }
run: |
touch sitemap.txt # this ensures that the sitemap detects itself
find . -type f -printf "${BASE_URL}/%P\n" | sed -e 's/\(\.html\)*$//g' | sort --unique | tee -a sitemap.txt
- name: "Create a Pages Artifact"
uses: actions/upload-pages-artifact@v1
with:
path: .
- name: "Deploy Pages"
uses: actions/deploy-pages@v1