Skip to content

Commit

Permalink
fix: Periodic workflow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
riscait committed Apr 5, 2024
1 parent e499fe7 commit 30933df
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/update-all-lint-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ concurrency:
cancel-in-progress: true

env:
branch: "update-all-lint-rules"
branch: "update-all-lint-rules-${{ github.run_number }}"

jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
has_diff: ${{ steps.output.outputs.has_diff }}
has_diff: ${{ steps.check_diff.outputs.has_diff }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
Expand All @@ -29,48 +29,49 @@ jobs:
--file "../altive_lints/lib/all_lint_rules.yaml" \
--query-selector "pre code" \
--verbose
- name: output diff
id: output
run: echo "diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_ENV"
- name: Create branch
if: env.diff_count != '0'
- name: Check for changes
id: check_diff
run: |
git switch -c ${{ env.branch }}
git push origin ${{ env.branch }}
- name: Git config
diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)
echo "diff_count=$diff_count" >> "$GITHUB_ENV"
if [ "$diff_count" -ne "0" ]; then
echo "has_diff=true" >> "$GITHUB_OUTPUT"
else
echo "has_diff=false" >> "$GITHUB_OUTPUT"
fi
- name: Create branch, configure git, commit & push
if: env.diff_count != '0'
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
if: env.diff_count != '0'
run: |
git switch -c ${{ env.branch }}
git add .
git commit -m "feat: update all_lint_rules"
git push origin ${{ env.branch }}
- name: Output flag
run: echo "has_diff=${{ env.diff_count != '0' }}" >> "$GITHUB_OUTPUT"
pull-request:
name: Create Pull-Request
runs-on: ubuntu-latest
needs: [update]
if: ${{ needs.update.outputs.has_diff == 'true' }}
needs: update
if: needs.update.outputs.has_diff == 'true'
steps:
- uses: actions/checkout@v4
- name: Generate GiHub App token
- name: Generate GitHub 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 }}"

run: |
gh pr create \
--base "$GITHUB_REF" \
--head ${{ env.branch }} \
--title "feat: Update all lint rules" \
--body "Automated pull request to update lint rules." \
--assignee "$GITHUB_ACTOR"
- name: Revoke GitHub Apps token
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
Expand Down

0 comments on commit 30933df

Please sign in to comment.