Skip to content

feat: add requirement tracing with mantra (#4) #1

feat: add requirement tracing with mantra (#4)

feat: add requirement tracing with mantra (#4) #1

Workflow file for this run

name: mantra-sync
on:
push:
branches: main
permissions:
contents: write
jobs:
# Synchronizes references between project and wiki.
mantra-sync:
runs-on: ubuntu-latest
container:
image: manuelhatzl/mantra:main
env:
BRANCH_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
with:
repository: 'mhatzl/evident-wiki'
path: './wiki'
# PAT with 'workflow' permission required in case wiki-links in workflow files get updated
token: ${{ secrets.EVIDENT_TOKEN }}
- uses: actions/checkout@v3
with:
path: './proj_folder'
- name: sync-references
run: mantra sync --branch-name=$BRANCH_NAME --branch-link=https://github.com/mhatzl/evident/tree/$BRANCH_NAME ./wiki/5-Requirements ./proj_folder
- name: job-date
id: job-date
# '-u' for UTC
run: |
echo "date=$(date -u +'%Y-%m-%d_%H:%M UTC')" >> $GITHUB_OUTPUT
- name: update-sidebar
run: |
sed -i -r "s/\*\*Last update:\*\*.+/\*\*Last update:\*\* ${{ steps.job-date.outputs.date }} /" ./wiki/_Sidebar.md
repo=$(echo "${{ github.repository }}")
repo=${repo//\//\\/}
sed -i -r "s/\*\*Repository:\*\*.+/\*\*Repository:\*\* $repo /" ./wiki/_Sidebar.md
sed -i -r "s/\*\*Branch:\*\*.+/\*\*Branch:\*\* $BRANCH_NAME /" ./wiki/_Sidebar.md
short_sha=$(echo "${{ github.sha }}")
short_sha=${short_sha:0:7}
commit_link=$(echo "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}")
commit_link=${commit_link//\//\\/}
sed -i -r "s/\*\*Commit:\*\*.+/\*\*Commit:\*\* \[$short_sha\]\($commit_link\) /" ./wiki/_Sidebar.md
- name: push-changes
working-directory: ./wiki
# In case nothing changed
continue-on-error: true
run: |
git config user.name github-actions
git config user.email [email protected]
git status
git add .
git commit -m "chore: sync references between wiki and project"
git push