From 5ef1bf6e7dc06aefee6e72a5867ca52991d01c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elian=20=E2=98=95=EF=B8=8F?= Date: Mon, 11 Oct 2021 21:56:50 +0200 Subject: [PATCH] Add Github Action to automatically push from main to latest when no changeset (#1529) * Add CI for updates on main to latest * Add folder checking on .changeset * Check JSON value of changeset * Update push script on action * Update commit and push job --- .github/workflows/updatelatest.yml | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/updatelatest.yml diff --git a/.github/workflows/updatelatest.yml b/.github/workflows/updatelatest.yml new file mode 100644 index 0000000000..635334fbc2 --- /dev/null +++ b/.github/workflows/updatelatest.yml @@ -0,0 +1,54 @@ +name: 'Update Latest from main' + +on: + push: + branches: + - "main" + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + update: + name: check for updates in .changeset + runs-on: ubuntu-latest + outputs: + run_job: ${{ steps.check_files.outputs.run_job }} + steps: + - name: checkout git branch + uses: actions/checkout@v2 + + - name: Install all dependencies + run: yarn + + - name: check modified files + run: npx changeset status --output ./status.json + + - name: check output + id: check_files + run: | + output=`echo $(cat status.json)` + if [[ $output = '{ "changesets": [], "releases": [] }' ]] + then + echo 'No changeset found' + echo "::set-output name=run_job::true" + else + echo 'changes found, push to latest skipped' + echo "::set-output name=run_job::false" + fi + + + update_latest_branch: + name: Update the latest branch + needs: update + if: needs.update.outputs.run_job == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Push + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: latest \ No newline at end of file