Update Anthology of Discourses [html] #1923
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: "tagged-release" | |
on: | |
push: | |
branches: | |
- "main" | |
permissions: | |
contents: write | |
jobs: | |
check_files: | |
name: "Check files" | |
runs-on: "ubuntu-latest" | |
outputs: | |
FILES_UPDATED: ${{ steps.compare_commits.outputs.FILES_UPDATED }} | |
DATE: ${{ steps.compare_commits.outputs.DATE }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
- id: compare_commits | |
shell: pwsh | |
run: | | |
# Check if 'last_run_date' file was changed in the latest commit | |
$LastCommitDiff = git diff --name-only HEAD^ HEAD | Where-Object { $_ -match "^last_run_date$" } | |
$DateChanged = $LastCommitDiff.Length -gt 0 | |
# Check if any publication was updated during last SuttaPublisher run | |
# (compare next to last and third to last commits) | |
$NextToLastCommitDiff = git diff --name-only HEAD^^ HEAD^ | Where-Object { $_ -notmatch "^(last_run_date|\.\/github.*)$" } | |
$PublicationsChanged = $NextToLastCommitDiff.Length -gt 0 | |
# Save output | |
$FilesUpdated = $DateChanged -and $PublicationsChanged | |
"FILES_UPDATED=$FilesUpdated" >> $env:GITHUB_OUTPUT | |
$Date = Get-Date -Format 'yyyy-MM-dd' | |
"DATE=$Date" >> $env:GITHUB_OUTPUT | |
make_release: | |
name: Make release | |
runs-on: ubuntu-latest | |
needs: check_files | |
if: needs.check_files.outputs.FILES_UPDATED == 'True' | |
steps: | |
- uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: false | |
automatic_release_tag: "editions-${{ needs.check_files.outputs.DATE }}" | |
- uses: dev-drprasad/delete-older-releases@v0.2.0 | |
with: | |
keep_latest: 1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |