From f55b746a8bf971e99926ffa5b996dcea7d3c76c8 Mon Sep 17 00:00:00 2001 From: Christian Zunker <827818+czunker@users.noreply.github.com> Date: Tue, 30 Jan 2024 07:09:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Automatically=20create=20cnquery=20?= =?UTF-8?q?update=20PR=20(#1045)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new cnquery release should trigger this workflow to create a PR which update the dep. Signed-off-by: Christian Zunker --- .github/pr-body.md | 4 ++ .github/workflows/cnquery-update.yml | 64 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/pr-body.md create mode 100644 .github/workflows/cnquery-update.yml diff --git a/.github/pr-body.md b/.github/pr-body.md new file mode 100644 index 00000000..df7dd72c --- /dev/null +++ b/.github/pr-body.md @@ -0,0 +1,4 @@ +Created by Mondoo Tools via GitHub Actions + +Workflow: +https://github.com/mondoohq/cnspec/actions/workflows/cnquery-update.yaml \ No newline at end of file diff --git a/.github/workflows/cnquery-update.yml b/.github/workflows/cnquery-update.yml new file mode 100644 index 00000000..9c81067f --- /dev/null +++ b/.github/workflows/cnquery-update.yml @@ -0,0 +1,64 @@ +name: Bump cnquery + +on: + repository_dispatch: + types: [update-cnquery] + +jobs: + bump-cnquery: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: +# https://github.com/peter-evans/create-pull-request/issues/48 +# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#push-using-ssh-deploy-keys +# tl;dr: +# The GITHUB_TOKEN is limited when creating PRs from a workflow +# becasue of that we use a ssh key for which the limitations do not apply + - name: Checkout code + uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.CNSPEC_DEPLOY_KEY_PRIV }} + + - name: Import environment variables from file + run: cat ".github/env" >> $GITHUB_ENV + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ">=${{ env.golang-version }}" + cache: false + - name: Bump cnquery + run: | + MAJOR=$(echo "${{ github.event.client_payload.version }}" | cut -d. -f1) + go get go.mondoo.com/cnquery/${MAJOR}@${{ github.event.client_payload.version }} + go mod tidy + + - name: Prepare title and branch name + id: branch + run: | + BRANCH_NAME="version/cnquery_update_${{ github.event.client_payload.version }}" + COMMIT_MSG="🧹 Bump cnquery to ${{ github.event.client_payload.version }}" + echo "COMMIT_TITLE=${COMMIT_MSG}" >> $GITHUB_OUTPUT + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT + + - name: Create PR + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + base: main + labels: dependencies,go + committer: "Mondoo Tools " + commit-message: ${{ steps.branch.outputs.COMMIT_TITLE }} + author: "Mondoo Tools " + title: ${{ steps.branch.outputs.COMMIT_TITLE }} + branch: ${{ steps.branch.outputs.BRANCH_NAME }} + body-path: .github/pr-body.md + + - name: PR infos + if: ${{ steps.cpr.outputs.pull-request-number }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + +