Skip to content

Commit

Permalink
Merge pull request #34 from nostr-jp/fix-sync-workflow
Browse files Browse the repository at this point in the history
Fix sync workflow
  • Loading branch information
darashi authored Nov 21, 2023
2 parents d329b5c + b07ad7c commit 4281480
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,16 @@ on:
permissions: {}

jobs:
create_token:
sync:
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
token: ${{ steps.create.outputs.token }}
timeout-minutes: 10
steps:
- uses: tibdex/github-app-token@v2
id: create
id: create_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}

sync:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: create_token
env:
GITHUB_TOKEN: ${{ needs.create_token.outputs.token }}
steps:
- uses: actions/checkout@v4
with:
ref: main
Expand Down Expand Up @@ -72,13 +63,19 @@ jobs:
echo "diff_main=0" >> $GITHUB_OUTPUT
echo "main is in sync with upstream"
fi
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}

- name: Check if sync pull request exists
id: sync_pr_existence
run: |
echo "count=$(gh pr list --head sync --base main | wc -l)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}

- name: Create pull request if needed
if: ${{steps.sync_pr_existence.outputs.count == 0 && steps.sync.outputs.diff_main == 1}}
run: |
gh pr create --head "sync" --base "main" --title "Sync with upstream" --body ""
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}

0 comments on commit 4281480

Please sign in to comment.