Add /investigate command for Discord issue reports #885
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| pull_request: {} | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| issue_comment: | |
| types: [created, edited] | |
| jobs: | |
| decide-parameters: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Output environment | |
| run: | | |
| echo '${{ github.ref }}' | |
| echo <<-EOF | |
| ${{ toJSON(github.event) }} | |
| EOF | |
| outputs: | |
| # Run builds for all triggers; ideally we would reuse an existing build | |
| # for comment triggers, but since we don't currently push images on | |
| # non-deploy builds, that's not currently possible. | |
| should-build: true | |
| # Run tests for all non-comment triggers; | |
| # ignore non-PR comment triggers; | |
| # and for PR comment triggers, only run tests if they are explicitly | |
| # requested. | |
| should-test: >- | |
| ${{ | |
| github.event_name != 'issue_comment' || | |
| ( | |
| github.event.issue.pull_request && ( | |
| contains(github.event.comment.body, 'rerun tests, please') || | |
| contains(github.event.comment.body, 'Rerun tests, please') | |
| ) | |
| ) | |
| }} | |
| # Deploy for all main merges; | |
| # for non-main meges, deploy for all tags; | |
| # for comments, only deploy if explicitly requested; | |
| # and for PR comment triggers, only run deployments if they are | |
| # explicitly requested. | |
| should-deploy: >- | |
| ${{ | |
| github.ref == 'refs/heads/main' || | |
| startsWith(github.ref, 'refs/tags/') || | |
| ( | |
| github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && ( | |
| contains(github.event.comment.body, 'deploy, please') || | |
| contains(github.event.comment.body, 'Deploy, please') | |
| ) | |
| ) | |
| }} | |
| output-parameters: | |
| needs: decide-parameters | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Output parameters | |
| run: | | |
| echo '${{ toJSON(needs.decide-parameters.outputs) }}' | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: decide-parameters | |
| if: ${{ needs.decide-parameters.outputs.should-test == 'true' }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat ./.nvmrc)" > $GITHUB_OUTPUT | |
| id: nvm | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "${{ steps.nvm.outputs.NVMRC }}" | |
| cache: "pnpm" | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm test | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| needs: [test, decide-parameters] | |
| if: ${{ needs.decide-parameters.outputs.should-build == 'true' || needs.decide-parameters.outputs.should-deploy == 'true' }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat ./.nvmrc)" > $GITHUB_OUTPUT | |
| id: nvm | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "${{ steps.nvm.outputs.NVMRC }}" | |
| cache: "pnpm" | |
| - run: pnpm install --frozen-lockfile | |
| - name: Build docker image | |
| run: | | |
| echo $GITHUB_SHA > BUILD | |
| docker build . -f infrastructure/docker/Dockerfile -t gcr.io/thesis-ops-2748/valkyrie:$GITHUB_SHA | |
| - name: Authenticate push with GCP | |
| if: ${{ needs.decide-parameters.outputs.should-deploy == 'true' }} | |
| id: "auth-push" | |
| uses: "google-github-actions/auth@v0" | |
| with: | |
| credentials_json: "${{ secrets.GCP_GCR_CREDENTIALS }}" | |
| - name: Set up GCP tools | |
| if: ${{ needs.decide-parameters.outputs.should-deploy == 'true' }} | |
| uses: google-github-actions/setup-gcloud@v0 | |
| - name: Push docker image to GCP | |
| if: ${{ needs.decide-parameters.outputs.should-deploy == 'true' }} | |
| run: | | |
| # Set up docker to authenticate via gcloud command-line tool. | |
| gcloud auth configure-docker | |
| docker push gcr.io/thesis-ops-2748/valkyrie:${{ github.sha }} | |
| deploy: | |
| needs: [build-and-push-image, decide-parameters] | |
| if: ${{ needs.decide-parameters.outputs.should-deploy == 'true' }} | |
| uses: ./.github/workflows/deploy.yml | |
| with: | |
| docker-image-name: valkyrie | |
| docker-image-version: ${{ github.sha }} | |
| gcp-project-name: thesis-ops | |
| gcp-project-id: thesis-ops-2748 | |
| secrets: | |
| GCP_DEPLOY_CREDENTIALS: ${{ secrets.GCP_DEPLOY_CREDENTIALS }} | |
| # Deploy depends on a freshly built image. Force deploy instead runs when | |
| # someone requests a deploy from a comment, and bypasses tests and builds (as | |
| # these are expected to have run previously). | |
| force-deploy: | |
| needs: [decide-parameters] | |
| if: ${{ needs.decide-parameters.outputs.should-deploy == 'true' && needs.decide-parameters.outputs.should-build == 'false' }} | |
| uses: ./.github/workflows/deploy.yml | |
| with: | |
| docker-image-name: valkyrie | |
| docker-image-version: ${{ github.sha }} | |
| gcp-project-name: thesis-ops | |
| gcp-project-id: thesis-ops-2748 | |
| secrets: | |
| GCP_DEPLOY_CREDENTIALS: ${{ secrets.GCP_DEPLOY_CREDENTIALS }} | |
| lint: | |
| needs: [decide-parameters] | |
| if: ${{ needs.decide-parameters.outputs.should-build == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat ./.nvmrc)" > $GITHUB_OUTPUT | |
| id: nvm | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "${{ steps.nvm.outputs.NVMRC }}" | |
| cache: "pnpm" | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm lint |