Gh actions#
To use with github, add one or both of these to your repo
Important
These are here for completeness but urlfwd init should set these up
and urlfwd deploy --update can be used to maintain them, if this package is up to date
For autobuild when links.yml is edited#
add the following contents to .github/workflows/build.yml:
build.yml#
name: Make links and QR codes from source and deploy
on:
push:
branches:
- 'main'
jobs:
# Deploy job
build_deploy:
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install & build
run: |
pip install git+https://github.com/brownsarahm/urlfwd.git
- name: Build
run: |
urlfwd gen links -v -l
# delete (or comment out with a # the `genqrs` line to not build the QR codes)
- name: Generate QRs
run: |
urlfwd gen qrs
# by default the html files will be generated to go to ta dcs folder
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./docs/"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Form use#
By manually triggering the action bewlo, you can also use a gh action form instead of editing the yaml directly, the form will be named Add a link via form on the left panel (not the center, that is logs)
form_add.yml#
name: Add a link via form
on:
workflow_dispatch:
inputs:
new_key:
description: new key to create
required: true
forward_url:
description: url to foward to
jobs:
# Add the link to the links.yml
add_link:
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
contents: write
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install & build
# TODO: modify to create template file
run: |
pip install git+https://github.com/brownsarahm/urlfwd.git
urlfwd add -l ${{ github.event.inputs.new_key }} -u ${{ github.event.inputs.forward_url }}
urlfwd gen links --landing
- uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: add ${{ github.event.inputs.new_key }}
# glob pattern of files which should be added to the commit
file_pattern: 'links.yml'
# Optional. Options used by `git-push`.
# See https://git-scm.com/docs/git-push#_options
# push_options: '--force'
# Optional. Disable dirty check and always try to create a commit and push
skip_dirty_check: true
# Optional. Skip internal call to `git fetch`
skip_fetch: true
# Optional. Skip internal call to `git checkout`
skip_checkout: true
# Optional. Prevents the shell from expanding filenames.
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
disable_globbing: true