Skip to content

🐛 replace broken link #129

🐛 replace broken link

🐛 replace broken link #129

Workflow file for this run

name: Build PDF / Docx
on:
pull_request:
paths:
- 'agreements/**'
- 'bylaws/**'
- 'policies/**'
push:
branches:
- main
paths:
- 'agreements/**'
- 'bylaws/**'
- 'policies/**'
workflow_dispatch:
inputs:
create_release:
description: 'Create a dated release'
required: false
default: false
type: boolean
release_notes:
description: 'Optional release notes'
required: false
default: ''
type: string
env:
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
GH_BOT_NAME: "GitHub Action"
permissions:
contents: read
jobs:
main-root:
outputs:
is-main: ${{ steps.is-main-root.outputs.test }}
runs-on: ubuntu-latest
steps:
- name: Check if main branch
if: github.ref == 'refs/heads/main' && github.repository == 'commonhaus/foundation'
id: is-main-root
run: |
if [[ "${{github.event_name}}" == 'push' || "${{github.event_name}}" == 'workflow_dispatch' ]]; then
echo "test=true" >> "$GITHUB_OUTPUT"
fi
package:
name: Package PDFs
needs: main-root
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: convert md to pdf
env:
GIT_COMMIT: ${{ github.sha }}
GH_TOKEN: ${{ github.token }}
IS_PR: ${{ github.event_name == 'pull_request' }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: ./.github/docker-build-pdf.sh
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: pdf-output
path: output/public/*.pdf
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: docx-output
path: output/public/*.docx
- id: configure_git
shell: bash
run: |
git config user.name ${{ env.GH_BOT_NAME }}
git config user.email ${{ env.GH_BOT_EMAIL }}
- name: Inputs
run: |
echo "echo is-main='${{ needs.main-root.outputs.is-main }}'"
echo "create_release='${{ inputs.create_release }}'"
echo "release_notes='${{ inputs.release_notes }}'"
- name: Update snapshot tag
if: needs.main-root.outputs.is-main == 'true' && inputs.create_release != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Update tag for SNAPSHOT"
git push origin :refs/tags/SNAPSHOT
git tag -f SNAPSHOT
git push --tags
echo "Update SNAPSHOT release"
gh release upload SNAPSHOT --clobber output/public/*
# These must be done separately to correctly toggle draft flag
gh release edit SNAPSHOT -t "PDF snapshot" --prerelease
gh release view SNAPSHOT
gh release edit SNAPSHOT --draft=false
- name: Create dated release
if: needs.main-root.outputs.is-main == 'true' && inputs.create_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ inputs.release_notes }}
run: |
# Create date-based tag in format YYYY-MM-DD
DATE_TAG=$(date +'%Y-%m-%d')
# Check if tag already exists and create a versioned one if needed
if git rev-parse "$DATE_TAG" >/dev/null 2>&1; then
# Tag exists, create a versioned one (YYYY-MM-DD.N)
VERSION=1
while git rev-parse "$DATE_TAG.$VERSION" >/dev/null 2>&1; do
VERSION=$((VERSION + 1))
done
RELEASE_TAG="$DATE_TAG.$VERSION"
else
RELEASE_TAG="$DATE_TAG"
fi
echo "Creating release with tag: $RELEASE_TAG"
# Create and push the new tag
git tag "$RELEASE_TAG"
git push origin "$RELEASE_TAG"
if [ -z "$RELEASE_NOTES" ]; then
RELEASE_NOTES="Automated document release generated on ${DATE_TAG}"
fi
# Create a GitHub release using the tag
gh release create "$RELEASE_TAG" \
--title "Release $RELEASE_TAG" \
--notes "$RELEASE_NOTES" \
output/public/*
echo "Release $RELEASE_TAG created successfully"