Skip to content

Commit a982c4f

Browse files
authored
fix: switch from pull_request_target to pull_request (#85)
1 parent 7e4239f commit a982c4f

File tree

5 files changed

+84
-46
lines changed

5 files changed

+84
-46
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Dependabot Automerge"
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Test"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
automerge-dependabot:
11+
name: "Automerge Dependabot PR"
12+
if: >
13+
${{ github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success' &&
15+
github.actor == 'dependabot[bot]' }}
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
18+
GIT_AUTHOR_NAME: mparticle-automation
19+
GIT_AUTHOR_EMAIL: [email protected]
20+
GIT_COMMITTER_NAME: mparticle-automation
21+
GIT_COMMITTER_EMAIL: [email protected]
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: 'Download artifact'
25+
uses: actions/[email protected]
26+
with:
27+
script: |
28+
var artifacts = await github.actions.listWorkflowRunArtifacts({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
run_id: ${{ github.event.workflow_run.id }},
32+
});
33+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
34+
return artifact.name == "pr"
35+
})[0];
36+
var download = await github.actions.downloadArtifact({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
artifact_id: matchArtifact.id,
40+
archive_format: 'zip',
41+
});
42+
var fs = require('fs');
43+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
44+
- run: unzip pr.zip
45+
- name: 'Automerge PR'
46+
uses: actions/github-script@v3
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
var fs = require('fs');
51+
var issue_number = Number(fs.readFileSync('./NR'));
52+
await github.pulls.merge({
53+
owner: context.repo.owner,
54+
repo: context.repo.repo,
55+
pull_number: issue_number,
56+
merge_method: 'rebase'
57+
});

.github/workflows/pull-request-app-checks.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
uses: actions/checkout@v2
2020
with:
2121
submodules: recursive
22-
# - name: "Create Path Triggers"
23-
# uses: dorny/paths-filter@v2
24-
# id: changes
25-
# with:
26-
# base: main
27-
# ref: ${{ github.head_ref }}
28-
# filters: |
29-
# sample-app:
30-
# - '${{ inputs.app_relative_path }}/**'
22+
# - name: "Create Path Triggers"
23+
# uses: dorny/paths-filter@v2
24+
# id: changes
25+
# with:
26+
# base: main
27+
# ref: ${{ github.head_ref }}
28+
# filters: |
29+
# sample-app:
30+
# - '${{ inputs.app_relative_path }}/**'
3131
# - name: "Cancel workflow"
3232
# if: steps.changes.outputs.sample-app != 'true'
3333
# uses: andymckay/[email protected]

.github/workflows/pull-request.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
1-
name: "Pull Request Checks"
1+
name: "Build and Test"
22

3-
on: [ pull_request_target ]
3+
on: [ push, workflow_dispatch, pull_request ]
44

55
jobs:
66

77
higgs-shop-sample-app:
88
name: "Check Higgs Shop Sample App"
9-
uses: mParticle/mparticle-workflows/.github/workflows/android-sample-app-pull-request.yml@stable
9+
uses: mParticle/mparticle-android-sample-apps/.github/workflows/pull-request-app-checks.yml@main
1010
with:
1111
app_relative_path: "core-sdk-samples/higgs-shop-sample-app"
1212

1313
automerge-dependabot:
14-
name: "Automerge Dependabot PR"
14+
name: "Save PR Number for Dependabot Automerge"
1515
needs: [ higgs-shop-sample-app ]
16-
if: ${{ github.actor == 'dependabot[bot]' }}
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
19-
GIT_AUTHOR_NAME: mparticle-bot
20-
GIT_AUTHOR_EMAIL: [email protected]
21-
GIT_COMMITTER_NAME: mparticle-bot
22-
GIT_COMMITTER_EMAIL: [email protected]
16+
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
2317
runs-on: ubuntu-latest
2418
steps:
25-
- name: "Rebase Dependabot PR"
26-
uses: actions/github-script@v3
19+
- name: "Checkout PR branch"
20+
uses: actions/checkout@v2
2721
with:
28-
script: |
29-
github.pulls.merge({
30-
owner: context.repo.owner,
31-
repo: context.payload.repository.name,
32-
pull_number: context.payload.pull_request.number,
33-
merge_method: 'rebase'
34-
});
35-
rebase-development:
36-
name: "Rebase Development onto Dependabot Branch"
37-
needs: [ automerge-dependabot ]
38-
if: ${{ github.actor == 'dependabot[bot]' }}
39-
uses: mParticle/mparticle-workflows/.github/workflows/dependabot-rebase-development.yml@stable
22+
submodules: recursive
23+
fetch-depth: 0
24+
- name: "Save Pull Request Number"
25+
run: |
26+
mkdir -p ./pr
27+
echo ${{ github.event.number }} > ./pr/NR
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
name: pr
31+
path: pr/

.github/workflows/push.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

core-sdk-samples/higgs-shop-sample-app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath("com.android.tools.build:gradle:7.1.2")
8+
classpath("com.android.tools.build:gradle:7.2.1")
99
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
1010
}
1111
}

0 commit comments

Comments
 (0)