Skip to content

dispatch_publish

dispatch_publish #72

Workflow file for this run

name: Publish PDF release to website
on:
workflow_dispatch:
repository_dispatch:
types: [dispatch_publish]
jobs:
deploy_web:
runs-on: ubuntu-latest
steps:
- name: Get the release
uses: pozetroninc/github-action-get-latest-release@master
id: cv_release
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: "maxpowis/cv"
- name: Echo release tag name
run: echo "::debug::Found tag for LATEST release >> ${{ steps.cv_release.outputs.release }}"
- name: Download all pdf's from release
uses: robinraju/release-downloader@v1.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: "maxpowis/cv"
tag: ${{ steps.cv_release.outputs.release }}
out-file-path: "cv"
fileName: '*.pdf'
- name: Checkout github-pages repository
uses: actions/checkout@v2
with:
repository: maxpowis/maxpowis.github.io
token: ${{ secrets.API_TOKEN_GITHUB }}
path: ./github-pages
- name: Copy pdf files to github-pages
run: |
mkdir -p ./github-pages/assets/cv
rm -f ./github-pages/assets/cv/*
for file in cv/*.pdf; do
echo "Copying $file"
cp -R "$file" ./github-pages/assets/cv/
done
- name: Update redirects for regular pdf
run: |
rm -f ./github-pages/_redirects/cv.html
file=$(find ./cv -maxdepth 1 -type f | grep -v "DARK" | awk 'NR==1{print}' | xargs -I{} basename {})
cat << EOF > ./github-pages/_redirects/cv.html
---
permalink: /cv
destination: assets/cv/$file
canonical: true
---
EOF
- name: Update redirects for dark pdf
run: |
rm -f ./github-pages/_redirects/cv_dark.html
file=$(find ./cv -maxdepth 1 -type f | grep "DARK" | awk 'NR==1{print}' | xargs -I{} basename {})
cat << EOF > ./github-pages/_redirects/cv_dark.html
---
permalink: /cv_dark
destination: assets/cv/$file
canonical: true
---
EOF
- name: Commit and push changes github-pages repository
uses: cpina/github-action-push-to-another-repository@v1.7.2
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source-directory: 'github-pages'
destination-github-username: 'maxpowis'
destination-repository-name: 'maxpowis.github.io'
user-email: max.powis@gmail.com
target-branch: master
commit-message: "Updates from cv release ${{ steps.cv_release.outputs.release }}"