Merge pull request #1862 from YunoHost/cleanup_workflows

Simplify github workflows
This commit is contained in:
Salamandar 2024-06-02 20:40:10 +02:00 committed by GitHub
commit 064fa32a39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 25 deletions

View file

@ -1,29 +1,24 @@
name: Check / auto apply Black name: Check / auto apply Black
on: on:
push: push:
branches: branches: [ "dev" ]
- dev
jobs: jobs:
black: black:
name: Check / auto apply black name: Check / auto apply black
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check files using the black formatter - name: Check files using the black formatter
uses: psf/black@stable uses: psf/black@stable
id: black id: black
with: with:
options: "." options: "."
continue-on-error: true 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 - name: Create Pull Request
if: steps.check_files_changed.outputs.files_changed == 'true'
uses: peter-evans/create-pull-request@v6 uses: peter-evans/create-pull-request@v6
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -12,28 +12,18 @@ jobs:
steps: steps:
- name: Fetch the source code - name: Fetch the source code
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script - name: Run the updater script
id: run_updater id: run_updater
run: | 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 # Download n
wget https://raw.githubusercontent.com/tj/n/master/bin/n --output-document=helpers/vendor/n/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 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 - name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v6 uses: peter-evans/create-pull-request@v6
id: cpr
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update n to ${{ env.VERSION }} commit-message: Update n to ${{ env.VERSION }}
@ -41,7 +31,7 @@ jobs:
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>' author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false signoff: false
base: dev base: dev
branch: ci-auto-update-n-v${{ env.VERSION }} branch: ci-auto-update-n-${{ env.VERSION }}
delete-branch: true delete-branch: true
title: 'Upgrade n to ${{ env.VERSION }}' title: 'Upgrade n to ${{ env.VERSION }}'
body: | body: |