From 7903f6da6f37a69f5bc7278f2413bd8b5fd587d6 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Tue, 30 Jan 2024 09:59:04 -0800 Subject: [PATCH] GHA automation to merge code from jdk21u-dev --- .github/workflows/merge-from-upstream-tip.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/merge-from-upstream-tip.yml diff --git a/.github/workflows/merge-from-upstream-tip.yml b/.github/workflows/merge-from-upstream-tip.yml new file mode 100644 index 00000000000..b59c76350fd --- /dev/null +++ b/.github/workflows/merge-from-upstream-tip.yml @@ -0,0 +1,54 @@ +name: "Merge Latest Tag from Tip" +on: + schedule: + - cron: '0 14 * * 4' + workflow_dispatch: +jobs: + # To create personal access tokens, go to account settings, + # then developer settings. Create a legacy token, give it + # access to repos and workflows and other sensible things. + # To then create a secret for the workflow, go to the + # repository settings and create a new secret with the text + # of the access token. + merge-from-tip: + # We only want this to run in one repo + # if: github.repository == 'openjdk/shenandoah' + runs-on: ubuntu-latest + name: Merge latest tag + steps: + # Note that we are checking out the upstream fork here. + # If this automation runs in openjdk/shenandoah, remove + # the token and repository arguments. + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.WORKFLOWS }} + repository: openjdk/shenandoah-jdk21u + - name: Fetch latest tag + id: latest-tag + run: | + git remote add upstream https://github.com/openjdk/jdk21u-dev.git + git fetch upstream + echo "latest=$(git tag --list --sort=-creatordate | head -1)" >> "$GITHUB_OUTPUT" + - name: Reset the default branch with latest tag + run: | + git reset --hard ${{ steps.latest-tag.outputs.latest }} + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: Merge tag ${{ steps.latest-tag.outputs.latest }} + # Using the legacy personal access token seems to be + # required to create a pull request on a remote repo. + # We can revert this to a fine grained token when this + # workflow is running upstream. + token: ${{ secrets.PAT }} + branch: merge-${{ steps.latest-tag.outputs.latest }} + delete-branch: true + # Without this, this action will attempt to push the + # new branch to the remote fork (i.e. openjdk/shenandoah). + # When this workflow runs in that repo, we can remove this. + push-to-fork: ${{ github.repository }} + title: Merge openjdk/jdk21u-dev:master + body: Merges tag ${{ steps.latest-tag.outputs.latest }} +