From 2fdaa628c4ae82c0a002e33e0957a3f99d59fa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 8 Apr 2024 16:51:15 +0200 Subject: [PATCH] CI updates This is done by the automated script named upgrade-c2cciutils-to-1.7 --- .github/workflows/changelog.yaml | 51 ----------------- .github/workflows/main.yaml | 10 +++- .../workflows/pull-request-automation.yaml | 56 ++++++------------- 3 files changed, 24 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/changelog.yaml diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml deleted file mode 100644 index e1daf00e..00000000 --- a/.github/workflows/changelog.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Changelog Generator - -on: - schedule: - - cron: 0 0 * * 1,4 - push: - tags: - - '*.*.*' - -jobs: - changelog: - name: Changelog Generator - runs-on: ubuntu-22.04 - timeout-minutes: 30 - - steps: - - uses: actions/checkout@v4 - if: github.event_name == 'push' && github.ref_type == 'tag' - - name: Create release - run: |- - if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - gh release create ${{ github.ref_name }} --generate-notes || true - fi - env: - GH_TOKEN: ${{ secrets.GOPASS_CI_GITHUB_TOKEN }} - - if: github.event_name == 'push' && github.ref_type == 'tag' - - name: Get Date - id: get-date - run: echo "date=$(/bin/date -u "+%Y%m%d%H%M%S")" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - with: - path: .cache - key: automation-${{ steps.get-date.outputs.date }} - restore-keys: |+ - automation- - - - run: docker pull aeonphp/automation - - name: Generate changelog - run: >- - docker run --env=AEON_AUTOMATION_GH_TOKEN --rm --volume=$(pwd)/.cache:/cache aeonphp/automation - changelog:generate:all - ${{ github.repository }} - --github-release-update - --cache-path=/cache - --skip-from=dependabot-preview[bot] - --skip-from=dependabot[bot] - --skip-from=renovate[bot] - -v - env: - AEON_AUTOMATION_GH_TOKEN: ${{ secrets.GOPASS_CI_GITHUB_TOKEN }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 037f5a27..b2355c16 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -47,9 +47,13 @@ jobs: key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} restore-keys: "pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}\npre-commit-" - run: pre-commit run --all-files - env: - SKIP: poetry-lock - - run: git diff && false + - run: git diff --exit-code --patch > /tmp/pre-commit.patch || true + if: failure() + - uses: actions/upload-artifact@v4 + with: + name: Apply pre-commit fix.patch + path: /tmp/pre-commit.patch + retention-days: 1 if: failure() - name: Print environment information run: c2cciutils-env diff --git a/.github/workflows/pull-request-automation.yaml b/.github/workflows/pull-request-automation.yaml index 45ca5deb..31478d1c 100644 --- a/.github/workflows/pull-request-automation.yaml +++ b/.github/workflows/pull-request-automation.yaml @@ -26,6 +26,23 @@ jobs: with: script: |- console.log(context); + - name: Auto reviews GHCI updates + uses: actions/github-script@v7 + with: + script: |- + github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + event: 'APPROVE', + }) + if: |- + startsWith(github.head_ref, 'ghci/audit/') + && (github.event.pull_request.user.login == 'ghci-test[bot]' + || github.event.pull_request.user.login == 'ghci-int[bot]' + || github.event.pull_request.user.login == 'ghci[bot]') + && (github.event.action == 'opened' + || github.event.action == 'reopened') - name: Auto reviews Renovate updates uses: actions/github-script@v7 with: @@ -98,42 +115,3 @@ jobs: && startsWith(github.head_ref, 'snyk-fix/') && (github.event.action == 'opened' || github.event.action == 'reopened') - - name: Restart audit workflow - uses: actions/github-script@v7 - with: - script: |- - let runs = await github.rest.actions.listWorkflowRuns({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'audit.yaml', - per_page: 1, - }); - runs = runs.data.workflow_runs; - if (runs.length == 1 && runs[0].status != 'success') { - console.log(`Rerun workflow ${runs[0].id} ${runs[0].status}`); - github.rest.actions.reRunWorkflowFailedJobs({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: runs[0].id, - }); - } - if: |- - github.event.pull_request.user.login == 'c2c-bot-gis-ci-2' - && (startsWith(github.head_ref, 'snyk-fix/') - || startsWith(github.head_ref, 'dpkg-update/')) - && github.event.action == 'closed' - && github.event.pull_request.merged == true - - name: Auto close pre-commit.ci autoupdate - uses: actions/github-script@v7 - with: - script: |- - github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - state: 'closed', - }); - if: |- - github.event.pull_request.user.login == 'pre-commit-ci' - && (github.event.action == 'opened' - || github.event.action == 'reopened')