Skip to content

Commit

Permalink
[FIXUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Sep 12, 2024
1 parent f3e2a39 commit 9f1f449
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 52 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/checkVersions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ on:
type: string
required: false
default: ''
secrets:
githubBotPAT:
description: The personal access token (with scope 'public_repo') of the bot to push a required change to a PR branch in a fork.
required: false
#TODO: revise inputs once done

permissions: read-all
Expand All @@ -31,14 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Dump GitHub context
run: echo '${{ toJSON(github) }}'

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
#with:
#ref: '${{ github.event.pull_request.head.sha }}'
#persist-credentials: false #Opt out from persisting the default Github-token authentication in order to enable use of the bot's PAT when pushing below
# token: ${{ secrets.githubBotPAT }} TODO: alternativly use this and and just add the fork without basic auth below.

- name: Set up Java
uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2
Expand Down Expand Up @@ -68,6 +57,7 @@ jobs:

- name: Commit version increments, if any
run: |
set -x
if [[ $(git status --ignore-submodules --porcelain) != '' ]]; then
# Workspace is not clean, i.e. some version were changed
Expand All @@ -83,7 +73,7 @@ jobs:
git commit -m "Bump version(s) for ${streamVersion} stream"
git format-patch -1 HEAD --no-stat --output 'version_increments.patch'
# --no-prefix
echo '${{ github.event.pull_request.number }}' > 'github_pull_request_number.txt'
else
Expand Down
43 changes: 6 additions & 37 deletions .github/workflows/publishVersionCheckResults.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
name: Publish Version Check Results
on:
workflow_call:
inputs:
botName:
description: The name of the bot that adds the necessary version increment changes
type: string
required: true
botMail:
description: The name of the bot that adds the necessary version increment changes
type: string
required: true
secrets:
githubBotPAT:
description: The personal access token (with scope 'public_repo') of the bot to push a required change to a PR branch in a fork.
required: false

# TODO: check if we can derive some inputs from the original workflow or the git-patch

permissions: read-all

jobs:
Expand Down Expand Up @@ -45,8 +34,8 @@ jobs:
if: steps.search-patch.outputs.result
with:
ref: '${{ github.event.workflow_run.head_sha }}'
persist-credentials: false #Opt out from persisting the default Github-token authentication in order to enable use of the bot's PAT when pushing below
# token: ${{ secrets.githubBotPAT }} TODO: alternativly use this and and just add the fork without basic auth below.
persist-credentials: true # (Explicit) opt-in for persisting the bot's PAT for authentication when pushing below
token: ${{ secrets.githubBotPAT }}

- name: Download version increment git patch
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -64,14 +53,14 @@ jobs:
await exec.exec('unzip', ['patch.zip'])
let pr_number = Number(fs.readFileSync('github_pull_request_number.txt'))
core.setOutput('pull_request_number', pr_number)
core.info('The PR is: ' + pr_number)
await io.rmRF('patch.zip')
await io.rmRF('github_pull_request_number.txt')
- name: Apply and push version increment
id: git-commit
if: steps.search-patch.outputs.result
run: |
set -x
# Set initial placeholder name/mail and read it from the patch later
git config --global user.email 'foo@bar'
git config --global user.name 'Foo Bar'
Expand All @@ -90,29 +79,9 @@ jobs:
echo "$fileList" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
#git remote add 'fork' https://github.com/${{ github.event.workflow_run.head_repository.full_name }}.git
#git remote -v
#git push 'fork' 'HEAD:refs/heads/${{ github.event.workflow_run.head_branch }}'
git push \
"https://oauth2:${BOT_TOKEN}@github.com/${{ github.event.workflow_run.head_repository.full_name }}.git" \
'HEAD:refs/heads/${{ github.event.workflow_run.head_branch }}'
env:
BOT_TOKEN: ${{ secrets.githubBotPAT }}
# - name: 'Comment on PR'
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# let fs = require('fs');
# let issue_number = Number(fs.readFileSync('./pr_number'));
# await github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number,
# body: 'Thank you for the PR!'
# });


git remote add 'fork' https://github.com/${{ github.event.workflow_run.head_repository.full_name }}.git
git remote -v
git push 'fork' 'HEAD:refs/heads/${{ github.event.workflow_run.head_branch }}'
- name: Add information comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/version-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ on:
jobs:
check:
uses: HannesWell/eclipse.platform.releng.aggregator/.github/workflows/publishVersionCheckResults.yml@master
with:
botName: Eclipse Releng Bot
botMail: [email protected]
secrets:
githubBotPAT: ${{ secrets.HANNESWELL_PAT }}

0 comments on commit 9f1f449

Please sign in to comment.