Skip to content

Check all lint rule diffs #12

Check all lint rule diffs

Check all lint rule diffs #12

name: Check all lint rule diffs
on:
workflow_dispatch:
schedule:
- cron: '0 0 15 * *'
env:
branch: "update-all-lint-rules"
jobs:
diff:
name: Check diff
runs-on: ubuntu-latest
outputs:
has-diff: ${{ steps.output.outputs.has-diff }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './diffscrape/go.mod'
cache-dependency-path: './diffscrape/go.sum'
- name: Run go
working-directory: ./diffscrape
run: go run cmd/rules/main.go
- uses: technote-space/get-diff-action@v6
with:
FILES: |
all_lint_rules.yaml
- name: Output diff
id: output
run: echo "has-diff=${{ env.GIT_DIFF }}" >> "$GITHUB_OUTPUT"
commit:
name: Commit diff
runs-on: ubuntu-latest
needs: [diff]
if: ${{ needs.diff.outputs.has-diff }}
steps:
- uses: actions/checkout@v4
- name: Create branch
run: |
git switch -c ${{ env.branch }}
git push origin ${{ env.branch }}
- name: Git config
run: |
git remote set-url origin https://github-actions:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Commit & Push
run: |
git add .
git commit -m "feat: update all_lint_rules"
git push origin ${{ env.branch }}
pull-request:
name: Create Pull-Request
runs-on: ubuntu-latest
needs: [commit]
steps:
- uses: actions/checkout@v4
- name: Generate GiHub App token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.PR_WRITER_APP_ID }}
private_key: ${{ secrets.PR_WRITER_PRIVATE_KEY }}
- name: Create PR
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: gh pr create -B $GITHUB_REF -t ${{ env.branch }} -b "" -a $GITHUB_ACTOR -H ${{ env.branch }}
- name: Revoke GitHub Apps token
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
curl --location --silent --request DELETE \
--url "${GITHUB_API_URL}/installation/token" \
--header "Accept: application/vnd.github+json" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--header "Authorization: Bearer ${GITHUB_TOKEN}"