diff --git a/.github/scripts/update.sh b/.github/scripts/update.sh new file mode 100644 index 0000000..a3cf687 --- /dev/null +++ b/.github/scripts/update.sh @@ -0,0 +1,7 @@ + +LATEST_LTS_VERSION=$(curl -sL https://nodejs.org/download/release/index.json | jq -r '[.[] | select(.lts != false)] | first | .version | sub("^v"; "")') +for file in Dockerfile*; do + sed -i "s/ENV NODE_VERSION .*/ENV NODE_VERSION $LATEST_LTS_VERSION/g" "$file" +done +sed -i "s/Node.js [0-9]*\.[0-9]*\.[0-9]*/Node.js $LATEST_LTS_VERSION/g" README.md +echo "version=$LATEST_LTS_VERSION" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e07f10e..d5148c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Build on: - push: + pull_request: workflow_dispatch: jobs: get-matrix: @@ -78,3 +78,15 @@ jobs: build-args: ${{ matrix.build_args }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + results: + if: ${{ always() }} + runs-on: ubuntu-latest + name: Final Results + needs: [build] + steps: + - run: exit 1 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + }} diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..7b38a69 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,36 @@ +name: Update + +on: + schedule: + - cron: '0 23 */2 * *' + workflow_dispatch: + +jobs: + update-node-version: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Update + id: update + run: bash .github/scripts/update.sh + + - name: Create update PR + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.TOKEN }} + author: "Node.js GitHub Bot " + branch: update-branch + branch-suffix: short-commit-hash + base: main + commit-message: "Bump Node.js version to ${{ steps.update.outputs.version }}" + title: "Bump Node.js version to ${{ steps.update.outputs.version }}" + delete-branch: true + - name: Auto approve and merge + if: steps.cpr.outputs.pull-request-operation == 'created' + run: | + gh pr merge -R "${{ github.repository }}" --merge --auto "${{ steps.cpr.outputs.pull-request-number }}" + env: + GH_TOKEN: ${{ secrets.TOKEN }}