From fc0993dbf984e3e76ab11ef9c9a7d6f1cd7fa27d Mon Sep 17 00:00:00 2001 From: Himadri Sekhar Basu Date: Fri, 22 Jul 2022 11:49:29 +0530 Subject: [PATCH] Add workflow to update mamolinux/stable branch --- .github/workflows/update-stable.yml | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/update-stable.yml diff --git a/.github/workflows/update-stable.yml b/.github/workflows/update-stable.yml new file mode 100644 index 0000000..724f1df --- /dev/null +++ b/.github/workflows/update-stable.yml @@ -0,0 +1,50 @@ +# Automatically fetch and merge latest tag to mamolinux/stable for new stable releases +name: Update mamolinux/stable branch + +# Controls when the action will run. +on: + schedule: + # scheduled every day at 00:00 + - cron: '0 0 */1 * *' + + workflow_dispatch: # on button click + inputs: + branch: + description: 'Branch to merge to' + required: true + default: 'mamolinux/stable' # set the branch to merge to + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "sync-new-release" + sync-new-release: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@master + with: + fetch-depth: 0 + + # Set default branches when run as scheduled job + - name: Set the branches + env: + DEFAULT_UPSTREAM_BRANCH: 'master' # set the upstream branch to merge from + DEFAULT_BRANCH: 'mamolinux/stable' # set the branch to merge to + run: | + git checkout ${{ env.DEFAULT_UPSTREAM_BRANCH }} + echo "latest-tag=`git log --oneline | cut -d " " -f 2 | grep -E '^[0-9]' | head -1`" >> $GITHUB_ENV + echo "branch=${{ github.event.inputs.branch || env.DEFAULT_BRANCH }}" >> $GITHUB_ENV + + - name: Set Git config + run: | + git config --local user.email "actions@github.com" + git config --local user.name "Github Actions" + + - name: Update mamolinux/stable for new release + run: | + git checkout ${{ env.branch }} + git merge --ff-only ${{ env.latest-tag }} + git push -f