From 7c5b52db0e8a0a8dd80c0e03685b0b3e61e90128 Mon Sep 17 00:00:00 2001 From: Soumya Ranjan Mahunt Date: Thu, 31 Aug 2023 20:20:19 +0530 Subject: [PATCH] ci: fixed duplicate action on dependabot auto-commit (#21) * ci: fixed duplicate action on dependabot auto-commit * ci: fixed auto-merge not triggering action --- .github/workflows/main.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae001ba..ebeb1a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,10 +22,25 @@ jobs: name: Check requirements runs-on: ubuntu-latest outputs: - run: ${{ github.event_name != 'push' && !contains(github.event.head_commit.message, '[skip dependabot]') }} + run: ${{ github.event_name != 'push' && steps.skip.outputs.result != 'true' }} release: ${{ (steps.check_version_bump.outputs.release_type != '' && github.event_name == 'push') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true') }} steps: + - name: Checkout repository + if: github.event.pull_request.head.sha != '' + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Check dependabot skip commit + if: github.event.pull_request.head.sha != '' + id: skip + uses: actions/github-script@v6 + with: + script: | + const {stdout} = await exec.getExecOutput('git', ['show', '-s', '--format=%s']); + return stdout.includes('[skip dependabot]'); + - name: Check version bump if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'build(swift-org-website):')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true') id: check_version_bump @@ -408,7 +423,7 @@ jobs: - name: Auto-merge run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}" env: - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }} cd: name: Create release