diff options
| author | 2024-01-02 23:48:57 -0500 | |
|---|---|---|
| committer | 2024-01-03 03:15:07 -0500 | |
| commit | 9a31122c826a79dabc6800ec931d54364e725fff (patch) | |
| tree | 16d1401a368bf658dca0ac86eab70fbbc1564769 /.github | |
| parent | Merge pull request #12554 from german77/directconnect (diff) | |
| download | yuzu-9a31122c826a79dabc6800ec931d54364e725fff.tar.gz yuzu-9a31122c826a79dabc6800ec931d54364e725fff.tar.xz yuzu-9a31122c826a79dabc6800ec931d54364e725fff.zip | |
actions: android: Move trigger logic to be yuzu-android specific
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/android-merge.js | 43 | ||||
| -rw-r--r-- | .github/workflows/android-publish.yml | 4 |
2 files changed, 35 insertions, 12 deletions
diff --git a/.github/workflows/android-merge.js b/.github/workflows/android-merge.js index 7e02dc9e5..79446c76a 100644 --- a/.github/workflows/android-merge.js +++ b/.github/workflows/android-merge.js | |||
| @@ -10,7 +10,7 @@ const CHANGE_LABEL = 'android-merge'; | |||
| 10 | // how far back in time should we consider the changes are "recent"? (default: 24 hours) | 10 | // how far back in time should we consider the changes are "recent"? (default: 24 hours) |
| 11 | const DETECTION_TIME_FRAME = (parseInt(process.env.DETECTION_TIME_FRAME)) || (24 * 3600 * 1000); | 11 | const DETECTION_TIME_FRAME = (parseInt(process.env.DETECTION_TIME_FRAME)) || (24 * 3600 * 1000); |
| 12 | 12 | ||
| 13 | async function checkBaseChanges(github, context) { | 13 | async function checkBaseChanges(github) { |
| 14 | // query the commit date of the latest commit on this branch | 14 | // query the commit date of the latest commit on this branch |
| 15 | const query = `query($owner:String!, $name:String!, $ref:String!) { | 15 | const query = `query($owner:String!, $name:String!, $ref:String!) { |
| 16 | repository(name:$name, owner:$owner) { | 16 | repository(name:$name, owner:$owner) { |
| @@ -22,8 +22,8 @@ async function checkBaseChanges(github, context) { | |||
| 22 | } | 22 | } |
| 23 | }`; | 23 | }`; |
| 24 | const variables = { | 24 | const variables = { |
| 25 | owner: context.repo.owner, | 25 | owner: 'yuzu-emu', |
| 26 | name: context.repo.repo, | 26 | name: 'yuzu', |
| 27 | ref: 'refs/heads/master', | 27 | ref: 'refs/heads/master', |
| 28 | }; | 28 | }; |
| 29 | const result = await github.graphql(query, variables); | 29 | const result = await github.graphql(query, variables); |
| @@ -38,8 +38,8 @@ async function checkBaseChanges(github, context) { | |||
| 38 | return false; | 38 | return false; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | async function checkAndroidChanges(github, context) { | 41 | async function checkAndroidChanges(github) { |
| 42 | if (checkBaseChanges(github, context)) return true; | 42 | if (checkBaseChanges(github)) return true; |
| 43 | const query = `query($owner:String!, $name:String!, $label:String!) { | 43 | const query = `query($owner:String!, $name:String!, $label:String!) { |
| 44 | repository(name:$name, owner:$owner) { | 44 | repository(name:$name, owner:$owner) { |
| 45 | pullRequests(labels: [$label], states: OPEN, first: 100) { | 45 | pullRequests(labels: [$label], states: OPEN, first: 100) { |
| @@ -48,8 +48,8 @@ async function checkAndroidChanges(github, context) { | |||
| 48 | } | 48 | } |
| 49 | }`; | 49 | }`; |
| 50 | const variables = { | 50 | const variables = { |
| 51 | owner: context.repo.owner, | 51 | owner: 'yuzu-emu', |
| 52 | name: context.repo.repo, | 52 | name: 'yuzu', |
| 53 | label: CHANGE_LABEL, | 53 | label: CHANGE_LABEL, |
| 54 | }; | 54 | }; |
| 55 | const result = await github.graphql(query, variables); | 55 | const result = await github.graphql(query, variables); |
| @@ -182,7 +182,30 @@ async function mergePullRequests(pulls, execa) { | |||
| 182 | return mergeResults; | 182 | return mergeResults; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | async function resetBranch(execa) { | ||
| 186 | console.log("::group::Reset master branch"); | ||
| 187 | let hasFailed = false; | ||
| 188 | try { | ||
| 189 | await execa("git", ["remote", "add", "source", "https://github.com/yuzu-emu/yuzu.git"]); | ||
| 190 | await execa("git", ["fetch", "source"]); | ||
| 191 | const process1 = await execa("git", ["rev-parse", "source/master"]); | ||
| 192 | const headCommit = process1.stdout; | ||
| 193 | |||
| 194 | await execa("git", ["reset", "--hard", headCommit]); | ||
| 195 | } catch (err) { | ||
| 196 | console.log(`::error title=Failed to reset master branch`); | ||
| 197 | hasFailed = true; | ||
| 198 | } | ||
| 199 | console.log("::endgroup::"); | ||
| 200 | if (hasFailed) { | ||
| 201 | throw 'Failed to reset the master branch. Aborting!'; | ||
| 202 | } | ||
| 203 | } | ||
| 204 | |||
| 185 | async function mergebot(github, context, execa) { | 205 | async function mergebot(github, context, execa) { |
| 206 | // Reset our local copy of master to what appears on yuzu-emu/yuzu - master | ||
| 207 | await resetBranch(execa); | ||
| 208 | |||
| 186 | const query = `query ($owner:String!, $name:String!, $label:String!) { | 209 | const query = `query ($owner:String!, $name:String!, $label:String!) { |
| 187 | repository(name:$name, owner:$owner) { | 210 | repository(name:$name, owner:$owner) { |
| 188 | pullRequests(labels: [$label], states: OPEN, first: 100) { | 211 | pullRequests(labels: [$label], states: OPEN, first: 100) { |
| @@ -193,8 +216,8 @@ async function mergebot(github, context, execa) { | |||
| 193 | } | 216 | } |
| 194 | }`; | 217 | }`; |
| 195 | const variables = { | 218 | const variables = { |
| 196 | owner: context.repo.owner, | 219 | owner: 'yuzu-emu', |
| 197 | name: context.repo.repo, | 220 | name: 'yuzu', |
| 198 | label: CHANGE_LABEL, | 221 | label: CHANGE_LABEL, |
| 199 | }; | 222 | }; |
| 200 | const result = await github.graphql(query, variables); | 223 | const result = await github.graphql(query, variables); |
| @@ -209,7 +232,7 @@ async function mergebot(github, context, execa) { | |||
| 209 | await fetchPullRequests(pulls, "https://github.com/yuzu-emu/yuzu", execa); | 232 | await fetchPullRequests(pulls, "https://github.com/yuzu-emu/yuzu", execa); |
| 210 | const mergeResults = await mergePullRequests(pulls, execa); | 233 | const mergeResults = await mergePullRequests(pulls, execa); |
| 211 | await generateReadme(pulls, context, mergeResults, execa); | 234 | await generateReadme(pulls, context, mergeResults, execa); |
| 212 | await tagAndPush(github, context.repo.owner, `${context.repo.repo}-android`, execa, true); | 235 | await tagAndPush(github, 'yuzu-emu', `yuzu-android`, execa, true); |
| 213 | } | 236 | } |
| 214 | 237 | ||
| 215 | module.exports.mergebot = mergebot; | 238 | module.exports.mergebot = mergebot; |
diff --git a/.github/workflows/android-publish.yml b/.github/workflows/android-publish.yml index 8f46fcf74..68e21c2f2 100644 --- a/.github/workflows/android-publish.yml +++ b/.github/workflows/android-publish.yml | |||
| @@ -16,7 +16,7 @@ on: | |||
| 16 | jobs: | 16 | jobs: |
| 17 | android: | 17 | android: |
| 18 | runs-on: ubuntu-latest | 18 | runs-on: ubuntu-latest |
| 19 | if: ${{ github.event.inputs.android != 'false' && github.repository == 'yuzu-emu/yuzu' }} | 19 | if: ${{ github.event.inputs.android != 'false' && github.repository == 'yuzu-emu/yuzu-android' }} |
| 20 | steps: | 20 | steps: |
| 21 | # this checkout is required to make sure the GitHub Actions scripts are available | 21 | # this checkout is required to make sure the GitHub Actions scripts are available |
| 22 | - uses: actions/checkout@v3 | 22 | - uses: actions/checkout@v3 |
| @@ -33,7 +33,7 @@ jobs: | |||
| 33 | script: | | 33 | script: | |
| 34 | if (context.payload.inputs && context.payload.inputs.android === 'true') return true; | 34 | if (context.payload.inputs && context.payload.inputs.android === 'true') return true; |
| 35 | const checkAndroidChanges = require('./.github/workflows/android-merge.js').checkAndroidChanges; | 35 | const checkAndroidChanges = require('./.github/workflows/android-merge.js').checkAndroidChanges; |
| 36 | return checkAndroidChanges(github, context); | 36 | return checkAndroidChanges(github); |
| 37 | - run: npm install execa@5 | 37 | - run: npm install execa@5 |
| 38 | if: ${{ steps.check-changes.outputs.result == 'true' }} | 38 | if: ${{ steps.check-changes.outputs.result == 'true' }} |
| 39 | - uses: actions/checkout@v3 | 39 | - uses: actions/checkout@v3 |