Skip to content

Check all lint rule diffs #16

Check all lint rule diffs

Check all lint rule diffs #16

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:
diff_count: ${{ steps.output.outputs.diff_count }}
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/cmd/rules
run: go run main.go
- name: output diff
id: output
run: echo "diff_count=$(git diff --name-only origin/${{ github.base_ref }} HEAD --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_OUTPUT"
commit:
name: Commit diff
runs-on: ubuntu-latest
needs: [diff]
if: ${{ needs.diff.outputs.diff_count != '0' }}
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}"