Skip to content

Instantly share code, notes, and snippets.

@fbjorn
Created March 18, 2021 08:26
Show Gist options
  • Save fbjorn/c887e6d39f4dca818056f98ee02b1a9c to your computer and use it in GitHub Desktop.
Save fbjorn/c887e6d39f4dca818056f98ee02b1a9c to your computer and use it in GitHub Desktop.
GitHub Actions pipeline for deploying static files to GitHub Pages without 3rd party dependencies.
name: Deploy to GitHub pages
on:
push:
branches:
- master
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare dist dir
run: mkdir dist && touch dist/hello.txt
- name: Deploy to GitHub Pages
if: success()
run: |
SRC="$(pwd)"
mkdir /tmp/github-pages && cd /tmp/github-pages
git init . && git checkout --orphan "${BRANCH}"
cp -r "${SRC}/${DEPLOY_DIR}"/* .
[[ ! -z "${FQDN}" ]] && echo "${FQDN}" > CNAME
git config user.name "GitHub" && git config user.email "<[email protected]>"
git add . && git status && git commit --message "${MESSAGE}"
git push -f -q "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "${BRANCH}"
env:
DEPLOY_DIR: dist
FQDN: your.pretty.domain # remove if you use default username.github.io/repo-name
MESSAGE: Deploy to GitHub Pages
BRANCH: gh-pages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment