From 2d2379828319cf97e06300587a1e1855a7ed526b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 2 Jun 2024 20:34:19 +0200 Subject: [PATCH] Simplify github workflow: peter-evans/create-pull-request@v6 already checks if diff exists --- .github/workflows/autoblack.yml | 15 +++++---------- .github/workflows/n_updater.yml | 20 +++++--------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml index 369f88824..561cad656 100644 --- a/.github/workflows/autoblack.yml +++ b/.github/workflows/autoblack.yml @@ -1,29 +1,24 @@ name: Check / auto apply Black + on: push: - branches: - - dev + branches: [ "dev" ] + jobs: black: name: Check / auto apply black runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Check files using the black formatter uses: psf/black@stable id: black with: options: "." continue-on-error: true - - shell: pwsh - id: check_files_changed - run: | - # Diff HEAD with the previous commit - $diff = git diff - $HasDiff = $diff.Length -gt 0 - Write-Host "::set-output name=files_changed::$HasDiff" + - name: Create Pull Request - if: steps.check_files_changed.outputs.files_changed == 'true' uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/n_updater.yml b/.github/workflows/n_updater.yml index 7d4dee940..0632f1836 100644 --- a/.github/workflows/n_updater.yml +++ b/.github/workflows/n_updater.yml @@ -12,28 +12,18 @@ jobs: steps: - name: Fetch the source code uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script id: run_updater run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' # Download n wget https://raw.githubusercontent.com/tj/n/master/bin/n --output-document=helpers/vendor/n/n - # Proceed only if there is a change - [[ -z "$(git diff helpers/vendor/n/n)" ]] || echo "PROCEED=true" >> $GITHUB_ENV + echo "VERSION=$(sed -n 's/^VERSION=\"\(.*\)\"/\1/p' < n)" >> $GITHUB_ENV - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade n to v$VERSION" + - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} uses: peter-evans/create-pull-request@v6 + id: cpr with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update n to ${{ env.VERSION }} @@ -41,7 +31,7 @@ jobs: author: 'yunohost-bot ' signoff: false base: dev - branch: ci-auto-update-n-v${{ env.VERSION }} + branch: ci-auto-update-n-${{ env.VERSION }} delete-branch: true title: 'Upgrade n to ${{ env.VERSION }}' body: |