From c2f70bc430e517527cf46f45d511a3408eec5047 Mon Sep 17 00:00:00 2001 From: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:33:24 +0530 Subject: [PATCH] CI: add continuous (PREVIEW) releases (#16) * CI: add continuous (PREVIEW) releases * add: debug job * add: more debug * update: `if` condition of workflow Job * fix: Label removal for workflows * update: remove debugging job, Fix removal of label, Add `synchronize` event for workflows * fix: labels env inputted as separate args in `run` command of workflows * fix: update installation step for pkg-pr-new * update: parse the labels as string in remove label workflow step * fix: `To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable` * add: workflows perms * add: list files to workflow for debugging - Finding the causes why `yarn` is detected as pkg Manager instead of `npm` * add: paths to include & exclude, Add trigger for push event for Workflows * fix: github event name condition for workflows --- .../workflows/continuous-Preview-releases.yml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/continuous-Preview-releases.yml diff --git a/.github/workflows/continuous-Preview-releases.yml b/.github/workflows/continuous-Preview-releases.yml new file mode 100644 index 0000000..23a658c --- /dev/null +++ b/.github/workflows/continuous-Preview-releases.yml @@ -0,0 +1,58 @@ +name: continuous (Preview) releases +# avoids paths like tests folder, .md, and anything that starts with `.` +# also avoids tags. +on: + workflow_dispatch: + pull_request_review: + types: [submitted] + pull_request: + types: [labeled, synchronize] + paths: + - 'build/**' + - '!tests/**' + - '!*.md' + - '!.*' + push: + paths: + - 'build/**' + - '!tests/**' + - '!*.md' + - '!.*' + branches: [main] + tags: + - "!**" + +permissions: + pull-requests: write + + +jobs: + approved: + if: github.event.review.state == 'APPROVED' && !contains(github.event.pull_request.labels.*.name, 'DO NOT PREVIEW RELEASE') || contains(github.event.pull_request.labels.*.name, 'Bypass check - PREVIEW RELEASE') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'PR Manual CI RUN')) + || contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - run: corepack enable + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + + - name: Install pkg-pr-new & prebuild, dependencies + run: npm install pkg-pr-new --save-dev --no-frozen-lockfile + + - run: ls -la + + - run: npx pkg-pr-new publish + + - name: Remove Manual PR Run label + if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'PR Manual CI RUN') + run: gh pr edit $PR --remove-label "$labels" + env: + PR: ${{ github.event.pull_request.number }} + labels: 'PR Manual CI RUN' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}