From 0a47b3335eab7e490b3c2b2946a62ab8b563d42c Mon Sep 17 00:00:00 2001 From: Pascal Pickel Date: Wed, 24 Jan 2024 14:59:56 +0100 Subject: [PATCH] ci: add reusable workflow actions --- .github/workflows/build.yml | 24 ++++++++++++++++++++++++ .github/workflows/labels.yml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/labels.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..032cf0154 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ + +name: Build App + +on: + workflow_call + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: 'npm' + + - name: Install Dependencies + run: npm ci + - name: Run all checks + run: npm run check + - name: Run Tests + run: npm test + - name: Build for Production + run: npm run build:prod diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 000000000..72edddd8e --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,35 @@ +name: Check labels + +on: + workflow_call: + +env: + GH_TOKEN: ${{ github.token }} + +jobs: + check_labels: + runs-on: ubuntu-latest + steps: + - name: 'Check for required labels' + if: > + contains(github.event.pull_request.labels.*.name, 'doc required') == false && + contains(github.event.pull_request.labels.*.name, 'doc not required') == false + run: echo "missing_label=true" >> "$GITHUB_ENV" + + - name: 'Notify user if label is missing' + if: env.missing_label == 'true' + run: | + URL="${{ github.event.pull_request.html_url }}" + COMMENT_TEXT="Required 'doc required' or 'doc not required label" + if [[ ! $(gh pr view $URL --json comments --jq '.comments[].body | select(. | contains("'"$COMMENT_TEXT"'"))') ]]; then + gh pr comment $URL --body "$COMMENT_TEXT" + fi + + - name: 'Fail' + uses: actions/github-script@v7 + if: env.missing_label == 'true' + with: + script: core.setFailed('Required "doc required" or "doc not required" label') + + +