Skip to content

Commit

Permalink
[FIXUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Sep 2, 2024
1 parent 3157c31 commit a980457
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
47 changes: 35 additions & 12 deletions .github/workflows/checkVersions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,47 +60,68 @@ jobs:
#TODO: exclude products, p2-repos etc:
# https://stackoverflow.com/questions/13266470/how-do-i-exclude-certain-modules-from-a-maven-build-using-the-commandline
# Do something like -pl '!excludedProject.replace(',','!,')'
# Or create a list of all eclipse-plugin and eclipse-feature projects and use it here as input for PL?! Could be done with java-script?!

#TODO: Derive stream version from something

- id: git-commit
name: Commit and push version increments, if any
run: |
set -x
if [[ $(git status --ignore-submodules --porcelain) != '' ]]; then
# Workspace is not clean, i.e. some version were changed
echo "version-incremented=true" >> $GITHUB_OUTPUT
git config --global user.email '${{ inputs.botMail }}'
git config --global user.name '${{ inputs.botName }}'
git add --all *
git add --all
git status
git commit -m "Bump version(s) for 4.34 stream"
fileList=$(git diff-tree --no-commit-id --name-only HEAD -r)
echo "file-list<<EOF" >> $GITHUB_OUTPUT
echo "$fileList" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
git format-patch -1 HEAD --output 'version_increments.patch'
git format-patch -1 HEAD --no-prefix --no-stat --output 'version_increments.patch'
#git remote add 'fork' https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
#git remote -v
#git push 'fork' 'HEAD:refs/heads/${{ github.event.pull_request.head.ref }}'
git push \
'https://oauth2:${BOT_TOKEN}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git' \
'HEAD:refs/heads/${{ github.event.pull_request.head.ref }}'
else
echo 'No versions have to be incremented'
echo "version-incremented=false" >> $GITHUB_OUTPUT
fi
#TODO: Derive version from something
# TODO: create patch in one of the previous steps and assign it to an output variable using gith-actions syntax:
#https://git-scm.com/docs/git-format-patch
#TODO: do the same for the list of files:
# https://stackoverflow.com/questions/424071/how-do-i-list-all-the-files-in-a-commit
# Use https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-output-parameter
env:
BOT_TOKEN: ${{ secrets.githubBotPAT }}

- name: Push version bump commit
if: steps.git-commit.outputs.version-incremented
if: ${{ ! steps.git-commit.outputs.version-incremented }}
run: |
echo 'Inc: ${{ steps.git-commit.outputs.version-incremented }}'
echo 'full_name: ${{ github.event.pull_request.head.repo.full_name }}'
echo 'head-ref1: ${{ github.event.pull_request.head.ref }}'
echo 'head-ref2: ${{ github.head_ref }}'
git remote add 'fork' https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
git remote -v
git push 'fork' 'HEAD:refs/heads/${{ github.event.pull_request.head.ref }}'
#git push 'fork' 'HEAD:refs/heads/${{ github.event.pull_request.head.ref }}'
git push \
'https://oauth2:${BOT_TOKEN}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git' \
'HEAD:refs/heads/${{ github.event.pull_request.head.ref }}'
env:
BOT_TOKEN: ${{ secrets.githubBotPAT }}
#TODO: Push it like in https://github.com/ad-m/github-push-action/blob/77c5b412c50b723d2a4fbc6d71fb5723bcd439aa/start.sh#L52
#TODO: use an env-variable to pass the token?!

- name: Add information comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
#TODO: Or use the gh CLI ? https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
#Or https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment
# Chose what can use the configured bot's identity?!
# See https://github.com/actions/github-script?tab=readme-ov-file#using-a-separate-github-token
if: steps.git-commit.outputs.version-incremented
with:
script: |
Expand All @@ -125,8 +146,10 @@ jobs:
github.rest.issues.createComment({
issue_number: context.issue.number, ...context.repo, body: commentBody.trim()
})
#TODO: make version dynamic and mail and bot name configurable?!
#Do all post-processing in a single java-script action step and use https://github.com/actions/toolkit/tree/main/packages/exec to run commands
# Or do everything in one single run-step and use the gh cli https://cli.github.com/manual/gh_api to create a comment?!
# https://cli.github.com/manual/gh_issue_comment
# https://cli.github.com/manual/gh_auth


# See
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
botName: Eclipse Releng Bot
botMail: [email protected]
secrets:
githubBotPAT: ${{ secrets.ECLIPSE_GITLAB_API_TOKEN }}
githubBotPAT: ${{ secrets.HANNESWELL_PAT }}

0 comments on commit a980457

Please sign in to comment.