setup-best-of-list #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
| # Based on https://github.com/best-of-lists/best-of/blob/main/.github/workflows/setup-best-of-list.yml | |
| name: setup-best-of-list | |
| on: | |
| workflow_dispatch: | |
| env: | |
| DEFAULT_BRANCH: "main" | |
| SETUP_BRANCH: "setup" | |
| PLACEHOLDER_REPO: "best-of-lists/best-of-template" | |
| jobs: | |
| setup-best-of-list: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: create-update-branch | |
| uses: peterjgrainger/action-create-branch@v3.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| branch: ${{ env.SETUP_BRANCH }} | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ env.SETUP_BRANCH }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: setup-template | |
| shell: bash | |
| run: | | |
| echo $GITHUB_REPOSITORY | |
| rm -rf history config latest-changes.md README.md projects.yaml ./.github/workflows/setup-best-of-list.yml CONTRIBUTING.md create-best-of-list.md | |
| mkdir -p ./config | |
| cp ./template/footer.md ./config/footer.md | |
| cp ./template/header.md ./config/header.md | |
| cp ./template/projects.yaml ./projects.yaml | |
| cp ./template/CONTRIBUTING.md ./CONTRIBUTING.md | |
| rm -rf ./template/ | |
| sed -i 's:${{ env.PLACEHOLDER_REPO }}:'$GITHUB_REPOSITORY':g' ./config/footer.md | |
| sed -i 's:${{ env.PLACEHOLDER_REPO }}:'$GITHUB_REPOSITORY':g' ./config/header.md | |
| sed -i 's:${{ env.PLACEHOLDER_REPO }}:'$GITHUB_REPOSITORY':g' ./CONTRIBUTING.md | |
| sed -i 's:'$(echo "${{ env.PLACEHOLDER_REPO }}" | sed "s:.*/::")':'$(echo "$GITHUB_REPOSITORY" | sed "s:.*/::")':g' ./config/header.md | |
| - name: push-update | |
| uses: stefanzweifel/git-auto-commit-action@v6 | |
| with: | |
| branch: ${{ env.SETUP_BRANCH }} | |
| commit_user_name: best-of setup | |
| commit_user_email: actions@github.com | |
| commit_message: Initial setup for best-of list | |
| skip_dirty_check: true | |
| commit_options: "--allow-empty" | |
| - name: create-pull-request | |
| shell: bash | |
| run: | | |
| # Stops script execution if a command has an error | |
| set -e | |
| curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2 | |
| bin/hub pull-request -b ${{ env.DEFAULT_BRANCH }} -h ${{ env.SETUP_BRANCH }} --no-edit -m "Initial setup for best-of list" -m "To finish this setup: Select <code>Merge pull request</code> below and <code>Confirm merge</code>." || true | |
| rm bin/hub | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: sync-labels | |
| # Alternative actions: | |
| # https://github.com/crazy-max/ghaction-github-labeler | |
| # https://github.com/EndBug/label-sync | |
| uses: micnncim/action-label-syncer@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| manifest: ".github/labels.yml" | |
| prune: true |