Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
blog/.github/workflows/main.yml
View runs Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
132 lines (112 sloc)
3.37 KB
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 Site and Deploy" | |
on: | |
push: | |
branches: "release" | |
pull_request: | |
env: | |
GITHUB_PR_NUMBER: "${{github.event.number}}" | |
PREVIEW_PATH: "./preview" | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
- name: Install Nix | |
uses: cachix/install-nix-action@v12 | |
with: | |
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install | |
extra_nix_config: | | |
experimental-features = nix-command flakes | |
- name: Compile Document | |
run: nix run ./#compile | |
- name: Disable Jekyll rendering | |
run: touch build/site/.nojekyll | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: blog-build | |
path: ./build/site | |
deploy-preview: | |
name: Deploy Preview | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Start deployment | |
uses: bobheadxi/deployments@v1 | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: preview (#${{ env.GITHUB_PR_NUMBER }}) | |
desc: Preview deployment of PR \#${{ env.GITHUB_PR_NUMBER }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Download Preview Repo | |
uses: actions/checkout@v2 | |
with: | |
repository: ysndr/beta | |
ref: gh-pages | |
path: preview | |
- name: Untrack preview | |
run: rm -rf ./preview/.git | |
- name: Download Current Build | |
uses: actions/download-artifact@v2 | |
with: | |
name: blog-build | |
path: current | |
- name: Apply Preview | |
run: | | |
export PR_PATH="$PREVIEW_PATH/$GITHUB_PR_NUMBER" | |
mkdir -p $PREVIEW_PATH | |
[ -d $PR_PATH ] && rm -r $PR_PATH | |
mv ./current $PR_PATH | |
- name: Deploy to GitHub | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
repo: ysndr/beta | |
target_branch: gh-pages | |
build_dir: ./preview | |
committer: github-ci <notifications+ci-blog@ysndr.de> | |
keep_history: true; | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | |
- name: Update deployment status | |
uses: bobheadxi/deployments@v1 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env: ${{ steps.deployment.outputs.env }} | |
env_url: https://ysndr.de/beta/${{ env.GITHUB_PR_NUMBER }} | |
deploy-release: | |
name: Deploy Release | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Download Current Build | |
uses: actions/download-artifact@v2 | |
with: | |
name: blog-build | |
path: release | |
- name: Deploy to GitHub | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
target_branch: gh-pages | |
build_dir: ./release | |
name: github-ci <notifications+ci-blog@ysndr.de> | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | |
always-run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Be friendly | |
run: | | |
echo "This is just here to prevent failure if the commit is not supposed to be build." | |
echo "Don't mind, have a joke :)" | |
echo "$(curl -Ss https://icanhazdadjoke.com/)" |