Skip to content

Commit

Permalink
✨ Add a workflow to update the graphql API once a week (#60)
Browse files Browse the repository at this point in the history
* ✨ Add a workflow to update the graphql API every Wednesday.

Signed-off-by: Preslav <[email protected]>

* Update .github/workflows/code-gen.yaml

Co-authored-by: Salim Afiune Maya <[email protected]>

* Add pr body.

Signed-off-by: Preslav <[email protected]>

---------

Signed-off-by: Preslav <[email protected]>
Co-authored-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
preslavgerchev and afiune authored Oct 21, 2024
1 parent ed41804 commit 5639cce
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/code-gen.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
commit-message: ${{ steps.branch.outputs.COMMIT_TITLE }}
author: "Mondoo Tools <[email protected]>"
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 }}"
4 changes: 4 additions & 0 deletions .github/workflows/pr-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Created by Mondoo Tools via GitHub Actions

Workflow:
https://github.com/mondoohq/mondoo-go/actions/workflows/code-gen.yaml

0 comments on commit 5639cce

Please sign in to comment.