From ea057eddf2b8206c6acde01fa654638c6335c622 Mon Sep 17 00:00:00 2001 From: Rob Jones Date: Thu, 20 Jun 2024 19:27:44 -0600 Subject: [PATCH] add more workflows --- .github/workflows/PR.yml | 63 +++++++++++++++++++++ .github/workflows/new-manifest-detected.yml | 55 ++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 .github/workflows/PR.yml create mode 100644 .github/workflows/new-manifest-detected.yml diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml new file mode 100644 index 0000000..8e58d5e --- /dev/null +++ b/.github/workflows/PR.yml @@ -0,0 +1,63 @@ +# This workflow runs when a PR is requested +name: Pull Request Flow +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: ['src/**', 'data/**', '.github/workflows/PR.yml', 'package.json', 'pnpm.lock'] + +# Ensures that only one deploy task per branch/environment will run at a time. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + if: github.event.pull_request.draft == false + env: + fork_pr: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + + runs-on: ubuntu-latest + steps: + - name: Checkout D2AI + uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: pnpm/action-setup@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: pnpm + + - name: Install + run: pnpm install --frozen-lockfile --prefer-offline + + - name: Generate Data + run: pnpm generate-data + + - name: porcelain check + uses: dorny/paths-filter@v3 + id: data + with: + base: HEAD + filters: | + changed: + - '**' + + - name: Commit other updated values + if: steps.data.outputs.changed == 'true' && !env.fork_pr + uses: stefanzweifel/git-auto-commit-action@v5.0.1 + with: + commit_message: other updates from manifest + commit_user_name: D2AI Bot + commit_user_email: destinyitemmanager@gmail.com + commit_author: D2AI Bot + + - name: Fail the Build w/ Note + if: steps.data.outputs.changed == 'true' && env.fork_pr + uses: actions/github-script@v7.0.1 + with: + script: | + core.setFailed('Please run `pnpm generate-data`') diff --git a/.github/workflows/new-manifest-detected.yml b/.github/workflows/new-manifest-detected.yml new file mode 100644 index 0000000..c50a2e3 --- /dev/null +++ b/.github/workflows/new-manifest-detected.yml @@ -0,0 +1,55 @@ +# This workflow runs when a new manifest is detected by cron +name: New Manifest Detected +on: + workflow_dispatch: + repository_dispatch: + types: [new-manifest-detected] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: pnpm/action-setup@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: pnpm + + - name: Install + run: pnpm install --frozen-lockfile --prefer-offline + + - name: Generate new D2AI information + run: pnpm generate-data + + - name: porcelain check + uses: dorny/paths-filter@v3 + id: D2AI-data + with: + base: HEAD + filters: | + changed: + - '**' + + - name: Create Pull Request + if: steps.D2AI-data.outputs.changed == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.PAT }} + commit-message: D2AI - Update All - Manifest v${{ github.event.client_payload.config.env.MANIFEST_VERSION }} + committer: D2AI Bot + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + title: '[D2AI] Manifest Update' + body: | + Manifest Update + - Update All - Manifest v${{ github.event.client_payload.config.env.MANIFEST_VERSION }} + - Auto-generated by [D2AI][1] + + [1]: https://github.com/DestinyItemManager/d2-additional-info + branch: d2ai-manifest-v${{ github.event.client_payload.config.env.MANIFEST_VERSION }}