From 34011c3816cd898a6cc83f45b0f166f2ba455790 Mon Sep 17 00:00:00 2001 From: Preslav Date: Mon, 21 Oct 2024 14:30:13 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Add=20a=20workflow=20to=20updat?= =?UTF-8?q?e=20the=20graphql=20API=20every=20Wednesday.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Preslav --- .github/workflows/code-gen.yaml | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/code-gen.yaml diff --git a/.github/workflows/code-gen.yaml b/.github/workflows/code-gen.yaml new file mode 100644 index 0000000..967ef59 --- /dev/null +++ b/.github/workflows/code-gen.yaml @@ -0,0 +1,60 @@ +name: "Update Graphql API" +on: + schedule: + - cron: "0 0 * * 3" + workflow_call: + workflow_dispatch: + +jobs: + update-graphql-api: + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Import environment variables from file + run: cat ".github/env" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ">=${{ env.golang-version }}" + cache: false + - name: Generate Graphql Schema + run: | + MONDOO_API_TOKEN=${{ secrets.MONDOO_API_TOKEN }} make generate + - name: Prepare title and branch name + id: branch + run: | + BRANCH_NAME="schema/update_$(date +'%Y%m%d%H%M%S')" + COMMIT_MSG="🧹 Bump Graphql Schema - $(date +'%Y%m%d%H%M%S')" + echo "COMMIT_TITLE=${COMMIT_MSG}" >> $GITHUB_OUTPUT + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT + - name: Check git diff + id: git-diff + run: | + git diff --exit-code . + echo "GIT_DIFF=$?" >> $GITHUB_OUTPUT + - name: Create PR + if: steps.git-diff.outputs.GIT_DIFF == '1' + id: cpr + uses: peter-evans/create-pull-request@v6 + 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 }}" + From e0dbae2d1b59c1c9f219d4ef9730e6aa81cc1f0e Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Mon, 21 Oct 2024 15:24:42 +0300 Subject: [PATCH 2/3] Update .github/workflows/code-gen.yaml Co-authored-by: Salim Afiune Maya --- .github/workflows/code-gen.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-gen.yaml b/.github/workflows/code-gen.yaml index 967ef59..652d8fe 100644 --- a/.github/workflows/code-gen.yaml +++ b/.github/workflows/code-gen.yaml @@ -30,7 +30,7 @@ jobs: id: branch run: | BRANCH_NAME="schema/update_$(date +'%Y%m%d%H%M%S')" - COMMIT_MSG="🧹 Bump Graphql Schema - $(date +'%Y%m%d%H%M%S')" + COMMIT_MSG="🧹 Bump GraphQL Schema - $(date +'%Y%m%d%H%M%S')" echo "COMMIT_TITLE=${COMMIT_MSG}" >> $GITHUB_OUTPUT echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT - name: Check git diff From de9e1eaaf624540e5239664249bbab96a3f9fa5d Mon Sep 17 00:00:00 2001 From: Preslav Date: Mon, 21 Oct 2024 15:29:58 +0300 Subject: [PATCH 3/3] Add pr body. Signed-off-by: Preslav --- .github/workflows/pr-body.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/workflows/pr-body.md diff --git a/.github/workflows/pr-body.md b/.github/workflows/pr-body.md new file mode 100644 index 0000000..b0616f6 --- /dev/null +++ b/.github/workflows/pr-body.md @@ -0,0 +1,4 @@ +Created by Mondoo Tools via GitHub Actions + +Workflow: +https://github.com/mondoohq/mondoo-go/actions/workflows/code-gen.yaml \ No newline at end of file