Skip to content

fix(actions): add workflows: write to auto check workflow (#166) #162

fix(actions): add workflows: write to auto check workflow (#166)

fix(actions): add workflows: write to auto check workflow (#166) #162

name: Initialise Repo

Check failure on line 1 in .github/workflows/auto-check-workflow.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/auto-check-workflow.yml

Invalid workflow file

(Line: 14, Col: 3): Unexpected value 'workflows'
on:
push:
branches:
# NB: its difficult to get the default branch dynamically in
# push event, so it has been hardcoded.
# ${{ github.event.repository.default_branch }} does not
# work in this scenario.
#
- main
permissions:
contents: write
workflows: write
jobs:
run-script:
name: run script
# We will only run this action when this repository isn't the
# template repository
#
if: >-
${{ !github.event.repository.is_template }}
runs-on: ubuntu-latest
steps:
- name: Configure Git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
shell: bash
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Run script
run: |
go run ./scripts/automate-checklist.go
shell: bash
- name: Go Format
run: |
go fmt ./...
shell: bash
- name: Go Mod Tidy
run: |
go mod tidy
shell: bash
- name: Clean up redundant scripts
run: |
rm -fv .github/workflows/auto-check-workflow.yml 2>/dev/null
rm -fv ./scripts/automate-checklist.sh 2>/dev/null
rm -fv ./scripts/automate-checklist.go 2>/dev/null
shell: bash
- name: Add files and commit changes
run: |
git add .
if [ -n "$(git status --porcelain)" ]; then
git commit -m "chore(gh-actions): apply auto-check edits"
git push -u origin ${{ github.event.repository.default_branch }}
else
echo "No changes to commit"
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}