Initial commit #1
This file contains hidden or 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: Initialise Repository | |
| on: | |
| push: | |
| branches: | |
| - main # first push triggers bootstrap | |
| permissions: | |
| contents: write | |
| jobs: | |
| bootstrap: | |
| # Only run for org repos and skip template repositories | |
| if: ${{ github.repository_owner == 'snivilised' && !github.event.repository.is_template }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repository using default github.token (always safe) | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| # Configure Git author | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Install Go version specified in go.mod | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| # Run automation script | |
| - name: Run automation script | |
| run: go run ./scripts/automate-checklist.go | |
| # Format code and tidy modules | |
| - name: Format & tidy Go | |
| run: | | |
| go fmt ./... | |
| go mod tidy | |
| # Remove bootstrap/template-only files | |
| - name: Clean up template scripts | |
| run: | | |
| rm -fv .github/workflows/auto-check-workflow.yml | |
| rm -fv ./scripts/automate-checklist.go | |
| rm -fv ./scripts/automate-checklist.sh | |
| # Commit & push changes using org PAT (no linter warning) | |
| - name: Commit & push changes | |
| env: | |
| ORG_PAT: ${{ secrets.AUTOMATION_PAT }} | |
| run: | | |
| git add . | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git commit -m "chore(repo): bootstrap repository" | |
| # Update remote URL to include PAT for push | |
| git remote set-url origin https://x-access-token:${ORG_PAT}@github.com/${GITHUB_REPOSITORY}.git | |
| git push origin HEAD:${{ github.event.repository.default_branch }} | |
| else | |
| echo "No changes to commit" | |
| fi | |