From 63c5febc532e93c20458a57432fab24d917a7309 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 12:59:39 +0100 Subject: merge buid & deploy CIs --- .github/workflows/build-deploy.yaml | 88 +++++++++++++++++++++++++++++++++++++ .github/workflows/build.yaml | 58 ------------------------ .github/workflows/deploy.yaml | 52 ---------------------- 3 files changed, 88 insertions(+), 110 deletions(-) create mode 100644 .github/workflows/build-deploy.yaml delete mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml new file mode 100644 index 00000000..cdfc84f9 --- /dev/null +++ b/.github/workflows/build-deploy.yaml @@ -0,0 +1,88 @@ +name: Build & Deploy + +on: + workflow_call: + inputs: + sha-tag: + description: "A short-form SHA tag for the commit that triggered this workflow" + required: true + type: string + + +jobs: + build: + name: Build Docker Image + runs-on: ubuntu-latest + + steps: + + - name: Checkout code + uses: actions/checkout@v3 + + # The current version (v3) of Docker's build-push action uses + # buildx, which comes with BuildKit features that help us speed + # up our builds using additional cache features. Buildx also + # has a lot of other features that are not as relevant to us. + # + # See https://github.com/docker/build-push-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Build the container, including an inline cache manifest to + # allow us to use the registry as a cache source. + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + cache-from: type=registry,ref=ghcr.io/python-discord/site:latest + cache-to: type=inline + tags: | + ghcr.io/python-discord/site:latest + ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }} + build-args: | + git_sha=${{ github.sha }} + + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + environment: production + + steps: + # Check out the private Kubernetes repository for the + # deployment.yaml file using a GitHub Personal Access + # Token to get access. + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: python-discord/kubernetes + + - uses: azure/setup-kubectl@v3 + + - name: Authenticate with Kubernetes + uses: azure/k8s-set-context@v3 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBECONFIG }} + + - name: Deploy to Kubernetes + uses: Azure/k8s-deploy@v4 + with: + manifests: | + namespaces/default/site/deployment.yaml + images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' + + - name: Purge Cloudflare Edge Cache + uses: jakejarvis/cloudflare-purge-action@master + env: + CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index bf9ec5b7..00000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: Build - -on: - workflow_run: - workflows: ["Lint & Test"] - branches: - - main - types: - - completed - -jobs: - build: - name: Build Docker Image - if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' - runs-on: ubuntu-latest - - steps: - # Create a commit SHA-based tag for the container repositories - - name: Create SHA Container Tag - id: sha_tag - run: | - tag=$(cut -c 1-7 <<< $GITHUB_SHA) - echo "tag=$tag" >> $GITHUB_OUTPUT - - - name: Checkout code - uses: actions/checkout@v3 - - # The current version (v3) of Docker's build-push action uses - # buildx, which comes with BuildKit features that help us speed - # up our builds using additional cache features. Buildx also - # has a lot of other features that are not as relevant to us. - # - # See https://github.com/docker/build-push-action - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Github Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Build the container, including an inline cache manifest to - # allow us to use the registry as a cache source. - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - push: true - cache-from: type=registry,ref=ghcr.io/python-discord/site:latest - cache-to: type=inline - tags: | - ghcr.io/python-discord/site:latest - ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }} - build-args: | - git_sha=${{ github.sha }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index f27690f0..00000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Deploy - -on: - workflow_run: - workflows: ["Build"] - branches: - - main - types: - - completed - -jobs: - deploy: - if: github.event.workflow_run.conclusion == 'success' - name: Deploy to Kubernetes Cluster - runs-on: ubuntu-latest - environment: production - - steps: - - name: Create SHA Container Tag - id: sha_tag - run: | - tag=$(cut -c 1-7 <<< $GITHUB_SHA) - echo "tag=$tag" >> $GITHUB_OUTPUT - - # Check out the private Kubernetes repository for the - # deployment.yaml file using a GitHub Personal Access - # Token to get access. - - name: Checkout code - uses: actions/checkout@v3 - with: - repository: python-discord/kubernetes - - - uses: azure/setup-kubectl@v3 - - - name: Authenticate with Kubernetes - uses: azure/k8s-set-context@v3 - with: - method: kubeconfig - kubeconfig: ${{ secrets.KUBECONFIG }} - - - name: Deploy to Kubernetes - uses: Azure/k8s-deploy@v4 - with: - manifests: | - namespaces/default/site/deployment.yaml - images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' - - - name: Purge Cloudflare Edge Cache - uses: jakejarvis/cloudflare-purge-action@master - env: - CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df - CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} -- cgit v1.2.3 From 96a251d224a0d1ebc984ab1397c055f6f8bd6cb7 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 12:59:50 +0100 Subject: call status_embed on CI completed --- .github/workflows/status_embed.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/status_embed.yaml b/.github/workflows/status_embed.yaml index e9b283cd..ead0f5ec 100644 --- a/.github/workflows/status_embed.yaml +++ b/.github/workflows/status_embed.yaml @@ -3,9 +3,7 @@ name: Status Embed on: workflow_run: workflows: - - Lint & Test - - Build - - Deploy + - CI types: - completed -- cgit v1.2.3 From 9af634069cf7c24667f6bd1f8cd63b2649db9faf Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 13:00:20 +0100 Subject: call status_embed from main CI This also passes the sha-tag as input --- .github/workflows/static-preview.yaml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/static-preview.yaml b/.github/workflows/static-preview.yaml index 9987aafe..c19ba05c 100644 --- a/.github/workflows/static-preview.yaml +++ b/.github/workflows/static-preview.yaml @@ -1,10 +1,12 @@ name: Build & Publish Static Preview on: - push: - branches: - - main - pull_request: + workflow_call: + inputs: + sha-tag: + description: "A short-form SHA tag for the commit that triggered this workflow" + required: true + type: string jobs: build: @@ -14,13 +16,6 @@ jobs: steps: - uses: actions/checkout@v3 - # Create a commit SHA-based tag for the container repositories - - name: Create SHA Container Tag - id: sha_tag - run: | - tag=$(cut -c 1-7 <<< $GITHUB_SHA) - echo "tag=$tag" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -43,7 +38,7 @@ jobs: cache-to: type=inline tags: | ghcr.io/python-discord/static-site:latest - ghcr.io/python-discord/static-site:${{ steps.sha_tag.outputs.tag }} + ghcr.io/python-discord/static-site:${{ inputs.sha_tag }} build-args: | git_sha=${{ github.sha }} STATIC_BUILD=TRUE @@ -53,7 +48,7 @@ jobs: run: | mkdir docker_build \ && docker run --entrypoint /bin/echo --name site \ - ghcr.io/python-discord/static-site:${{ steps.sha_tag.outputs.tag }} \ + ghcr.io/python-discord/static-site:${{ inputs.sha_tag }} \ && docker cp site:/app docker_build/ # Build directly to a local folder -- cgit v1.2.3 From 38c979aec2ca2364185266c36e807f6ecdd34788 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 13:00:30 +0100 Subject: add the main.yaml CI workflow --- .github/workflows/main.yaml | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..03b0e9b4 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + lint-test: + uses: ./.github/workflows/lint-test.yaml + + + generate-sha-tag: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + outputs: + sha-tag: ${{ steps.sha-tag.outputs.sha-tag }} + steps: + - name: Create SHA Container tag + id: sha-tag + run: | + tag=$(cut -c 1-7 <<< $GITHUB_SHA) + echo "sha-tag=$tag" >> $GITHUB_OUTPUT + + publish-static-preview: + uses: ./.github/workflows/static-preview.yaml + with: + sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }} + + + build-deploy: + if: github.ref == 'refs/heads/main' + uses: ./.github/worfklows/build-deploy.yaml + needs: + - lint-test + - generate-sha-tag + with: + sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }} + secrets: inherit + + + sentry-release: + if: github.ref == 'refs/heads/main' + uses: ./.github/workflows/sentry_release.yml + needs: + - build-deploy + secrets: inherit -- cgit v1.2.3 From 99ca1f946a9bb88ecd54f04b8ddfae96fa0a2fdc Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 13:56:37 +0100 Subject: always generate sha tag --- .github/workflows/main.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 03b0e9b4..fd47b5c0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,7 +18,6 @@ jobs: generate-sha-tag: - if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest outputs: sha-tag: ${{ steps.sha-tag.outputs.sha-tag }} -- cgit v1.2.3 From 493a9486f917fc0efb6badc7caf4c803696764d3 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 6 Mar 2023 13:58:16 +0100 Subject: correct typo in workflows --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fd47b5c0..9762ad73 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -36,7 +36,7 @@ jobs: build-deploy: if: github.ref == 'refs/heads/main' - uses: ./.github/worfklows/build-deploy.yaml + uses: ./.github/workflows/build-deploy.yaml needs: - lint-test - generate-sha-tag -- cgit v1.2.3 From 831ac621b9d39b495a1135cca4a0d5e092c9477d Mon Sep 17 00:00:00 2001 From: shtlrs Date: Tue, 7 Mar 2023 08:17:40 +0100 Subject: appease linter --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9762ad73..357777d1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,7 +27,7 @@ jobs: run: | tag=$(cut -c 1-7 <<< $GITHUB_SHA) echo "sha-tag=$tag" >> $GITHUB_OUTPUT - + publish-static-preview: uses: ./.github/workflows/static-preview.yaml with: -- cgit v1.2.3 From 43e83dcfd02ae129939fc4a14b2de0d5fe2f75d6 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Sun, 19 Mar 2023 17:51:43 +0100 Subject: align sentry-release file ext --- .github/workflows/main.yaml | 2 +- .github/workflows/sentry-release.yaml | 23 +++++++++++++++++++++++ .github/workflows/sentry-release.yml | 23 ----------------------- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/sentry-release.yaml delete mode 100644 .github/workflows/sentry-release.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 357777d1..8414f941 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -47,7 +47,7 @@ jobs: sentry-release: if: github.ref == 'refs/heads/main' - uses: ./.github/workflows/sentry_release.yml + uses: ./.github/workflows/sentry_release.yaml needs: - build-deploy secrets: inherit diff --git a/.github/workflows/sentry-release.yaml b/.github/workflows/sentry-release.yaml new file mode 100644 index 00000000..6521c389 --- /dev/null +++ b/.github/workflows/sentry-release.yaml @@ -0,0 +1,23 @@ +name: Create Sentry release + +on: + push: + branches: + - main + +jobs: + createSentryRelease: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Create a Sentry.io release + uses: tclindner/sentry-releases-action@v1.2.0 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: python-discord + SENTRY_PROJECT: site + with: + tagName: ${{ github.sha }} + environment: production + releaseNamePrefix: site@ diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml deleted file mode 100644 index 6521c389..00000000 --- a/.github/workflows/sentry-release.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Create Sentry release - -on: - push: - branches: - - main - -jobs: - createSentryRelease: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Create a Sentry.io release - uses: tclindner/sentry-releases-action@v1.2.0 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: python-discord - SENTRY_PROJECT: site - with: - tagName: ${{ github.sha }} - environment: production - releaseNamePrefix: site@ -- cgit v1.2.3 From d4e2325d822fc21d0fc7548d01596364792597d9 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Sun, 19 Mar 2023 17:53:05 +0100 Subject: make generate-sha-tag a dependency for publish-static-review --- .github/workflows/main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8414f941..6fa6baff 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -30,6 +30,8 @@ jobs: publish-static-preview: uses: ./.github/workflows/static-preview.yaml + needs: + - generate-sha-tag with: sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }} -- cgit v1.2.3 From ccebb846291ea2b6096723bbb419c14e31d38823 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Sun, 19 Mar 2023 18:12:53 +0100 Subject: fix indentation for secrets --- .github/workflows/main.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6fa6baff..58d98a55 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -6,17 +6,14 @@ on: - main pull_request: - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - jobs: lint-test: uses: ./.github/workflows/lint-test.yaml - generate-sha-tag: runs-on: ubuntu-latest outputs: @@ -35,7 +32,6 @@ jobs: with: sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }} - build-deploy: if: github.ref == 'refs/heads/main' uses: ./.github/workflows/build-deploy.yaml @@ -44,8 +40,7 @@ jobs: - generate-sha-tag with: sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }} - secrets: inherit - + secrets: inherit sentry-release: if: github.ref == 'refs/heads/main' -- cgit v1.2.3 From c297361f75762b5212b39ebf656f8608989600e9 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 20 Mar 2023 15:56:26 +0100 Subject: use workflow_call as trigger for lint-test --- .github/workflows/lint-test.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 1fe3bd89..3328c208 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -1,11 +1,7 @@ name: Lint & Test on: - push: - branches: - - main - pull_request: - + workflow_call jobs: lint-test: -- cgit v1.2.3 From 732a72f509e95eb78a32f4ad81339205707fa049 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 20 Mar 2023 20:17:22 +0100 Subject: use workflow_call as trigger for sentry-release This also updates the worklow's name --- .github/workflows/main.yaml | 2 +- .github/workflows/sentry-release.yaml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 58d98a55..6454737d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -44,7 +44,7 @@ jobs: sentry-release: if: github.ref == 'refs/heads/main' - uses: ./.github/workflows/sentry_release.yaml + uses: ./.github/workflows/sentry-release.yaml needs: - build-deploy secrets: inherit diff --git a/.github/workflows/sentry-release.yaml b/.github/workflows/sentry-release.yaml index 6521c389..ed42c980 100644 --- a/.github/workflows/sentry-release.yaml +++ b/.github/workflows/sentry-release.yaml @@ -1,9 +1,7 @@ name: Create Sentry release on: - push: - branches: - - main + workflow_call jobs: createSentryRelease: -- cgit v1.2.3 From 37d0001009308584282d00bbc02a46f272c07002 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 20 Mar 2023 20:18:22 +0100 Subject: use hyphen instead of underscore across all workflow names --- .github/workflows/status-embed.yaml | 76 +++++++++++++++++++++++++++++++++++++ .github/workflows/status_embed.yaml | 76 ------------------------------------- 2 files changed, 76 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/status-embed.yaml delete mode 100644 .github/workflows/status_embed.yaml diff --git a/.github/workflows/status-embed.yaml b/.github/workflows/status-embed.yaml new file mode 100644 index 00000000..ead0f5ec --- /dev/null +++ b/.github/workflows/status-embed.yaml @@ -0,0 +1,76 @@ +name: Status Embed + +on: + workflow_run: + workflows: + - CI + types: + - completed + +jobs: + status_embed: + # We need to send a status embed whenever the workflow + # sequence we're running terminates. There are a number + # of situations in which that happens: + # + # 1. We reach the end of the Deploy workflow, without + # it being skipped. + # + # 2. A `pull_request` triggered a Lint & Test workflow, + # as the sequence always terminates with one run. + # + # 3. If any workflow ends in failure or was cancelled. + if: >- + (github.event.workflow_run.name == 'Deploy' && github.event.workflow_run.conclusion != 'skipped') || + github.event.workflow_run.event == 'pull_request' || + github.event.workflow_run.conclusion == 'failure' || + github.event.workflow_run.conclusion == 'cancelled' + name: Send Status Embed to Discord + runs-on: ubuntu-latest + + steps: + # A workflow_run event does not contain all the information + # we need for a PR embed. That's why we upload an artifact + # with that information in the Lint workflow. + - name: Get Pull Request Information + id: pr_info + if: github.event.workflow_run.event == 'pull_request' + run: | + curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json + DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url') + [ -z "$DOWNLOAD_URL" ] && exit 1 + wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2 + unzip -p pull_request_payload.zip > pull_request_payload.json + [ -s pull_request_payload.json ] || exit 3 + echo "pr_author_login=$(jq -r '.user.login // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT + echo "pr_number=$(jq -r '.number // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT + echo "pr_title=$(jq -r '.title // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT + echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Send an informational status embed to Discord instead of the + # standard embeds that Discord sends. This embed will contain + # more information and we can fine tune when we actually want + # to send an embed. + - name: GitHub Actions Status Embed for Discord + uses: SebastiaanZ/github-status-embed-for-discord@v0.3.0 + with: + # Our GitHub Actions webhook + webhook_id: '784184528997842985' + webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} + + # Workflow information + workflow_name: ${{ github.event.workflow_run.name }} + run_id: ${{ github.event.workflow_run.id }} + run_number: ${{ github.event.workflow_run.run_number }} + status: ${{ github.event.workflow_run.conclusion }} + actor: ${{ github.actor }} + repository: ${{ github.repository }} + ref: ${{ github.ref }} + sha: ${{ github.event.workflow_run.head_sha }} + + pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }} + pr_number: ${{ steps.pr_info.outputs.pr_number }} + pr_title: ${{ steps.pr_info.outputs.pr_title }} + pr_source: ${{ steps.pr_info.outputs.pr_source }} diff --git a/.github/workflows/status_embed.yaml b/.github/workflows/status_embed.yaml deleted file mode 100644 index ead0f5ec..00000000 --- a/.github/workflows/status_embed.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Status Embed - -on: - workflow_run: - workflows: - - CI - types: - - completed - -jobs: - status_embed: - # We need to send a status embed whenever the workflow - # sequence we're running terminates. There are a number - # of situations in which that happens: - # - # 1. We reach the end of the Deploy workflow, without - # it being skipped. - # - # 2. A `pull_request` triggered a Lint & Test workflow, - # as the sequence always terminates with one run. - # - # 3. If any workflow ends in failure or was cancelled. - if: >- - (github.event.workflow_run.name == 'Deploy' && github.event.workflow_run.conclusion != 'skipped') || - github.event.workflow_run.event == 'pull_request' || - github.event.workflow_run.conclusion == 'failure' || - github.event.workflow_run.conclusion == 'cancelled' - name: Send Status Embed to Discord - runs-on: ubuntu-latest - - steps: - # A workflow_run event does not contain all the information - # we need for a PR embed. That's why we upload an artifact - # with that information in the Lint workflow. - - name: Get Pull Request Information - id: pr_info - if: github.event.workflow_run.event == 'pull_request' - run: | - curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json - DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url') - [ -z "$DOWNLOAD_URL" ] && exit 1 - wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2 - unzip -p pull_request_payload.zip > pull_request_payload.json - [ -s pull_request_payload.json ] || exit 3 - echo "pr_author_login=$(jq -r '.user.login // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT - echo "pr_number=$(jq -r '.number // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT - echo "pr_title=$(jq -r '.title // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT - echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Send an informational status embed to Discord instead of the - # standard embeds that Discord sends. This embed will contain - # more information and we can fine tune when we actually want - # to send an embed. - - name: GitHub Actions Status Embed for Discord - uses: SebastiaanZ/github-status-embed-for-discord@v0.3.0 - with: - # Our GitHub Actions webhook - webhook_id: '784184528997842985' - webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} - - # Workflow information - workflow_name: ${{ github.event.workflow_run.name }} - run_id: ${{ github.event.workflow_run.id }} - run_number: ${{ github.event.workflow_run.run_number }} - status: ${{ github.event.workflow_run.conclusion }} - actor: ${{ github.actor }} - repository: ${{ github.repository }} - ref: ${{ github.ref }} - sha: ${{ github.event.workflow_run.head_sha }} - - pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }} - pr_number: ${{ steps.pr_info.outputs.pr_number }} - pr_title: ${{ steps.pr_info.outputs.pr_title }} - pr_source: ${{ steps.pr_info.outputs.pr_source }} -- cgit v1.2.3 From 5e51c790ab544028f8febb79b52ff53f3512da7e Mon Sep 17 00:00:00 2001 From: shtlrs Date: Mon, 20 Mar 2023 20:20:57 +0100 Subject: fix indentation for k8s-deploy job's inputs --- .github/workflows/build-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml index cdfc84f9..9899d942 100644 --- a/.github/workflows/build-deploy.yaml +++ b/.github/workflows/build-deploy.yaml @@ -77,8 +77,8 @@ jobs: - name: Deploy to Kubernetes uses: Azure/k8s-deploy@v4 with: - manifests: | - namespaces/default/site/deployment.yaml + manifests: | + namespaces/default/site/deployment.yaml images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' - name: Purge Cloudflare Edge Cache -- cgit v1.2.3 From 36c9988028accc5eefaa61a630ccbb355fdd0067 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Tue, 21 Mar 2023 09:22:11 +0100 Subject: use provided sha-tag from input --- .github/workflows/build-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy.yaml b/.github/workflows/build-deploy.yaml index 9899d942..5007110d 100644 --- a/.github/workflows/build-deploy.yaml +++ b/.github/workflows/build-deploy.yaml @@ -47,7 +47,7 @@ jobs: cache-to: type=inline tags: | ghcr.io/python-discord/site:latest - ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }} + ghcr.io/python-discord/site:${{ inputs.sha_tag }} build-args: | git_sha=${{ github.sha }} @@ -79,7 +79,7 @@ jobs: with: manifests: | namespaces/default/site/deployment.yaml - images: 'ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}' + images: 'ghcr.io/python-discord/site:${{ inputs.sha_tag }}' - name: Purge Cloudflare Edge Cache uses: jakejarvis/cloudflare-purge-action@master -- cgit v1.2.3