From a63d69060cc014e65a22829fb1310db66f98e2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Cora=C3=A7=C3=A3o?= Date: Sat, 9 Mar 2024 21:26:04 +0000 Subject: [PATCH] new action for auto update --- .github/workflows/hugo-version-update.yml | 80 +++++++++++++---------- release-versions/hugo-latest.txt | 1 + 2 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 release-versions/hugo-latest.txt diff --git a/.github/workflows/hugo-version-update.yml b/.github/workflows/hugo-version-update.yml index effe1c2f..60481b31 100644 --- a/.github/workflows/hugo-version-update.yml +++ b/.github/workflows/hugo-version-update.yml @@ -1,43 +1,53 @@ name: Update Hugo version on: - schedule: - - cron: '60 1 * * *' + schedule: + - cron: '0 6 * * *' - workflow_dispatch: + workflow_dispatch: jobs: - updateBlowfish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - token: ${{ secrets.REPO_SCOPED_TOKEN }} - - name: Fetch release version - run: | - curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | \ - jq -r ".tag_name" > release-versions/swagger-ui-latest.txt - - name: Check for modified files - id: git-check - run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") - - name: Commit latest release version - if: steps.git-check.outputs.modified == 'true' - run: | - git config --global user.name 'Your Name' - git config --global user.email 'your-email@users.noreply.github.com' - git commit -am "New release version" - git push - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - commit-message: Update swagger-ui to ${{ steps.swagger-ui.outputs.release_tag }} - title: Update SwaggerUI to ${{ steps.swagger-ui.outputs.release_tag }} - body: | - Updates [swagger-ui][1] to ${{ steps.swagger-ui.outputs.release_tag }} + updateBlowfish: + runs-on: ubuntu-latest + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + with: + submodules: true # Fetch Hugo themes (true OR recursive) + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + + - name: Fetch release version + id: fetch-release + run: | + curl -sL https://api.github.com/repos/gohugoio/hugo/releases/latest | \ + jq -r ".tag_name" > release-versions/hugo-latest.txt + + - name: Check for modified files + id: git-check + run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") + + - name: Update config.toml + id: update-config + if: steps.git-check.outputs.modified == 'true' + run: | + cat release-versions/hugo-latest.txt | \ + while read version; do sed -i '' -E "s/(max = \")[0-9]+\.[0-9]+\.[0-9]+(\")/\1${version#v}\2/g" config.toml | + release_tag=$(cat release-versions/hugo-latest.txt) | \ + echo "release_tag=$release_tag" >> $GITHUB_OUTPUT + + - name: Create Pull Request + if: steps.git-check.outputs.modified == 'true' + uses: peter-evans/create-pull-request@v6 + with: + commit-message: Update Hugo supported version to ${{ steps.update-config.outputs.release_tag }} + title: Update Hugo supported version to ${{ steps.update-config.outputs.release_tag }} + body: | + Updates [Hugo][1] support to ${{ steps.update-config.outputs.release_tag }} - Auto-generated by [create-pull-request][2] + Auto-generated by [create-pull-request][2] - [1]: https://github.com/swagger-api/swagger-ui - [2]: https://github.com/peter-evans/create-pull-request - labels: dependencies, automated pr - branch: dev \ No newline at end of file + [1]: https://github.com/gohugoio/hugo + [2]: https://github.com/peter-evans/create-pull-request + labels: dependencies, automated pr + branch: dev \ No newline at end of file diff --git a/release-versions/hugo-latest.txt b/release-versions/hugo-latest.txt new file mode 100644 index 00000000..f960f387 --- /dev/null +++ b/release-versions/hugo-latest.txt @@ -0,0 +1 @@ +v0.123.1