diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 63e4c568..acf0ecb7 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -2,6 +2,16 @@ name: Auto-merge on: pull_request_target: types: ready_for_review + workflow_call: + inputs: + pr: + description: "Pull Request number" + type: number + required: true + url: + description: "Pull Request URL (HTML, not API)" + type: string + required: false permissions: contents: write @@ -11,7 +21,7 @@ jobs: approve: continue-on-error: true runs-on: ubuntu-latest - if: ${{ github.actor_id == github.repository_owner_id }} + if: ${{ github.actor_id == github.repository_owner_id || inputs.pr }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -38,7 +48,7 @@ jobs: } }' - ISSUES=$(gh api graphql -f query="$QUERY" -F prNumber=${{ github.event.pull_request.number }} -F repositoryName=${{ github.event.repository.name }} -F repositoryOwner=${{ github.event.repository.owner.login }} -q '.data.repository.pullRequest.closingIssuesReferences.nodes[] | .number') + ISSUES=$(gh api graphql -f query="$QUERY" -F prNumber=${{ github.event.pull_request.number || inputs.pr }} -F repositoryName=${{ github.event.repository.name }} -F repositoryOwner=${{ github.event.repository.owner.login }} -q '.data.repository.pullRequest.closingIssuesReferences.nodes[] | .number') echo "num=$ISSUES" >> "$GITHUB_OUTPUT" if [ -z "$ISSUES" ] @@ -54,7 +64,7 @@ jobs: - name: Approve # if there is no requested reviewers specified and PR don't have any linked issue's: if: success() && steps.reviewers.outputs.value == '0' - run: gh pr review --approve "${{ github.event.pull_request.html_url }}" + run: gh pr review --approve "${{ github.event.pull_request.html_url || inputs.url || inputs.pr }}" - name: Auto-merge # only if no linked issue: @@ -62,4 +72,4 @@ jobs: run: >- gh pr merge --auto --${{ github.event.pull_request.commits > 1 && 'squash' || 'merge' }} - "${{ github.event.pull_request.html_url }}" + "${{ github.event.pull_request.html_url || inputs.url || inputs.pr }}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6ba4789a..0bb5f325 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,11 @@ name: Tests on: workflow_call: + inputs: + ref: + description: git branch, tag or SHA to checkout. + type: string + required: true pull_request: push: branches: [main, master] @@ -57,6 +62,8 @@ jobs: steps: - run: arch - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Cache uses: actions/cache@v4 @@ -157,6 +164,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Cache uses: actions/cache@v4 @@ -210,6 +219,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Cache uses: actions/cache@v4 @@ -290,6 +301,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Cache uses: actions/cache@v4 @@ -356,6 +369,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: Check id: check @@ -373,5 +388,5 @@ jobs: continue-on-error: true if: success() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') # https://docs.github.com/en/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request - uses: parkerbxyz/suggest-changes@v1 + uses: parkerbxyz/suggest-changes@v1.0.4 # with: comment: Rustfmt suggested the formatting changes. diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 5152dc54..bd97f360 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -159,9 +159,8 @@ jobs: matrix: os: - macos-14 - # - macos-latest - ubuntu-latest - # - windows-latest + - windows-latest sdk: - ${{ github.event.inputs.sdk || 'latest' }} features: @@ -244,11 +243,12 @@ jobs: cargo build -p=playdate-sys --features="lang-items ${{ matrix.features.v }}" --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release - name: Commit + continue-on-error: true id: commit uses: EndBug/add-and-commit@v9 with: add: ./api/sys/gen/*.rs - author_name: Alex Koz + author_name: Update Bot author_email: boozook@users.noreply.github.com committer_name: Update Workflow message: Automated build pre-built bindings @@ -290,7 +290,7 @@ jobs: uses: EndBug/add-and-commit@v9.1.4 with: add: ./api/sys/Cargo.toml - author_name: Alex Koz + author_name: Bump Bot author_email: boozook@users.noreply.github.com committer_name: Bump sys version message: Automated bump sys crate version @@ -305,7 +305,7 @@ jobs: pr: name: Make PR - needs: [new-branch, pre-gen, pre-gen-arm] + needs: [new-branch, pre-gen, pre-gen-arm, bump, tests] runs-on: ubuntu-latest defaults: run: @@ -324,6 +324,7 @@ jobs: ref: ${{ needs.new-branch.outputs.working }} - name: Create PR + id: pr uses: TreTuna/sync-branches@1.4.0 with: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} @@ -332,12 +333,23 @@ jobs: PULL_REQUEST_TITLE: Update pre-built bindings PULL_REQUEST_BODY: | - [x] Pre-built bindings just updated. - - [ ] Bump sys crate + - [${{ needs.bump.result == 'success' && 'x' || ' ' }}] Bump sys crate + - [${{ needs.tests.result == 'success' && 'x' || ' ' }}] Tests passed PULL_REQUEST_IS_DRAFT: false CONTENT_COMPARISON: true REVIEWERS: '["boozook"]' + outputs: + number: ${{ steps.pr.outputs.PULL_REQUEST_NUMBER }} + url: ${{ steps.pr.outputs.PULL_REQUEST_URL }} + tests: name: Tests needs: [new-branch, pre-gen, pre-gen-arm] uses: ./.github/workflows/tests.yml secrets: inherit + permissions: + actions: read + contents: read + pull-requests: write + with: + ref: ${{ needs.new-branch.outputs.working }}