diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..9a89c65 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,52 @@ +name: Weekly Hugo Update + +on: + push: # Trigger on every push + branches: + - main + schedule: + - cron: '0 0 * * 0' + workflow_dispatch: + +jobs: + update-code: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get Latest Go Version + id: go-version + run: | + LATEST_GO_VERSION=$(curl -s "https://go.dev/VERSION?m=text" | sed 's/^go//') + echo "::set-output name=go_version::$LATEST_GO_VERSION" + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "${{ steps.go-version.outputs.go_version }}" + + - name: Install Hugo Extended + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: "latest" + extended: true + + - name: Update Go Version in go.mod + run: | + go mod edit -go="${{ steps.go-version.outputs.go_version }}" + + - name: Fetch Hugo Modules + run: | + hugo mod get + + - name: Commit and Push Changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + git add go.mod go.sum + git commit -m "Update Hugo modules and Go version [skip ci]" || echo "No changes to commit" + git push \ No newline at end of file