Templates
actions/checkout
steps:
- name: Checkout the repo!
uses: actions/checkout@v3
actions/cache
- uses: actions/cache@v3
with:
key: ${{ runner.os }}-mkdocs-$(date --utc '+%V')
path: .cache
restore-keys: |
${{ runner.os }}-mkdocs-
actions/upload-artifact
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: built-packages
path: ${{ github.workspace }}/*.pkg.tar.*
actions/download-artifact
- uses: actions/download-artifact@v3
with:
name: my-artifact # name of the artifact to download. If not specified, download all in nested directories
path: . # defaults to the workspace (in a nested dir if artifact name is not specified)
actions/github-script
- Run javascript code to fetch gh api
- name: Verify PR number
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const response = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context. repo.repo,
pull_number: ${{ github.event.inputs.PR_number }}
});
if (response.data.number !== ${{ github.events.inputs.PR_number }}) {
throw new Error("Invalid PR");
} else {
console.log("PR ref: " + response.data.head.ref);
return response.data.head.ref;
}
github.rest.issues.createComment({
issue_number: ${{ github.event.inputs.PR_number }},
owner: context.repo.owner,
body: output
})
actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: 3.x
actions/setup-node
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: ${{ steps.detect-package-manager.outputs.manager }}
actions/configure-pages
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
actions/upload-pages-artifact
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: |
pip install mkdocs
mkdocs get-deps | xargs pip install
mkdocs build
- uses: actions/upload-pages-artifact@v2
with:
path: ./site
actions/deploy-pages
- Expects an artifact named
github-pages
to have been created prior to execution.
- Outputs:
page_url
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
mxschmitt/action-tmate
- SSH into the runner machine for debugging purposes
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3