From b69929b12a9262e04209f98ecfe24097efd4c73b Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Fri, 25 Oct 2024 17:41:46 -0400 Subject: [PATCH] Update `update-dev.yml` to use `git` instead of third-party action (#1242) The `update-dev` action keeps failing due to unrelated histories between the `dev` and `master` branches, and the third party action used for the nightly merge does not include any options to allow merging with unrelated histories. So, this PR updates the action to use `git` instead. This will also give us more flexibility in the future. Couple of updates: * I have confirmed that configuring `git` using `secrets.NIGHTLY_TOKEN` does not expose the token in the workflow logs. See [here](https://github.com/PennyLaneAI/qml/actions/runs/11408914907/job/31748090296#step:3:4) for an example. [sc-76254] --------- Co-authored-by: Rashid N H M <95639609+rashidnhm@users.noreply.github.com> --- .github/workflows/update-dev.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-dev.yml b/.github/workflows/update-dev.yml index 55d89fa0db..3fc4a7bee9 100644 --- a/.github/workflows/update-dev.yml +++ b/.github/workflows/update-dev.yml @@ -27,12 +27,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + token: ${{ secrets.NIGHTLY_TOKEN }} - name: Nightly Merge - uses: robotology/gh-action-nightly-merge@v1.3.3 - with: - stable_branch: 'master' - development_branch: 'dev' - allow_ff: false env: - GITHUB_TOKEN: ${{ secrets.NIGHTLY_TOKEN }} + CONFIG_USERNAME: GitHub Nightly Merge Action + CONFIG_EMAIL: actions@github.com + MERGE_HEAD: master + MERGE_BASE: dev + MERGE_ARGS: --no-ff --allow-unrelated-histories --no-edit + run: | + # This script is adapted from the robotology/gh-action-nightly-merge@v1.5.2 GitHub action: + # https://github.com/robotology/gh-action-nightly-merge/blob/master/entrypoint.sh + + git config --global user.name "$CONFIG_USERNAME" + git config --global user.email "$CONFIG_EMAIL" + + git fetch origin $MERGE_HEAD + (git checkout $MERGE_HEAD && git pull) + + git fetch origin $MERGE_BASE + (git checkout $MERGE_BASE && git pull) + + git merge $MERGE_ARGS $MERGE_HEAD + git push origin $MERGE_BASE