From c9454bc6e6c8d7441b4a56040146c90e51705b64 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 27 Nov 2024 15:28:41 -0300 Subject: [PATCH] add official image PR automation --- .github/workflows/automatic-updates.yml | 3 +- .github/workflows/official-pr.yml | 67 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/official-pr.yml diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 4d632b4..60f3e62 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -23,8 +23,9 @@ jobs: - name: Create update PR id: cpr - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@v7 with: + token: ${{ secrets.GH_API_TOKEN }} author: "rocketchat-github-ci " branch: update-branch base: main diff --git a/.github/workflows/official-pr.yml b/.github/workflows/official-pr.yml new file mode 100644 index 0000000..c19ab79 --- /dev/null +++ b/.github/workflows/official-pr.yml @@ -0,0 +1,67 @@ +name: Create official images PR + +on: + pull_request_target: + types: + - closed + + paths: + - ".github/workflows/official-pr.yml" + - "**/Dockerfile" + - "stackbrew.js" + +jobs: + pr: + runs-on: ubuntu-latest + if: github.repository_owner == 'rocketchat' && github.event.pull_request.merged_by != '' + permissions: + pull-requests: write + + steps: + - name: Checkout the Docker.Official.Image repo + uses: actions/checkout@v4 + with: + path: Docker.Official.Image + ref: ${{ github.base_ref }} + fetch-depth: 50 + + - name: Checkout the official-images repo + uses: actions/checkout@v4 + with: + path: official-images + repository: docker-library/official-images + + - name: Generate Stackbrew for diff + run: | + cd Docker.Official.Image + ./stackbrew.js > ../official-images/library/rocket.chat + + - name: Create PR in official-images + id: create-pr + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GH_API_TOKEN }} + push-to-fork: rocketchat/official-images + path: official-images + branch: rocketchat + commit-message: "Rocket.Chat: ${{ github.event.pull_request.title }}" + title: "Rocket.Chat: ${{ github.event.pull_request.title }}" + body: | + Pull Request: ${{ github.event.pull_request.html_url }} + + - name: PR details + run: | + echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}" + + - name: Create PR comment + uses: peter-evans/create-or-update-comment@v4 + if: ${{ steps.create-pr.outputs.pull-request-url != '' }} + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Created PR on the official-images repo (${{ steps.create-pr.outputs.pull-request-url }}). See https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what if you are wondering when it will be available on the Docker Hub. + + - name: Dump context + if: always() + uses: crazy-max/ghaction-dump-context@v2