-
-
Notifications
You must be signed in to change notification settings - Fork 137
ci security #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ci security #1618
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,9 @@ jobs: | |
| steps: | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| persist-credentials: false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't even know it did this by default. Wow! |
||
|
|
||
| # The current version (v3) of Docker's build-push action uses | ||
| # buildx, which comes with BuildKit features that help us speed | ||
|
|
@@ -26,10 +28,10 @@ jobs: | |
| # | ||
| # See https://github.com/docker/build-push-action | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v4 | ||
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4 | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v4 | ||
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.repository_owner }} | ||
|
|
@@ -38,7 +40,7 @@ jobs: | |
| # 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@v7 | ||
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
|
|
@@ -59,29 +61,30 @@ jobs: | |
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| repository: python-discord/infra | ||
| path: infra | ||
| persist-credentials: false | ||
|
|
||
| - uses: azure/setup-kubectl@v5.1.0 | ||
| - uses: azure/setup-kubectl@829323503d1be3d00ca8346e5391ca0b07a9ab0d # v5.1.0 | ||
|
|
||
| - name: Authenticate with Kubernetes | ||
| uses: azure/k8s-set-context@v5 | ||
| uses: azure/k8s-set-context@89b837d75b40a7bd2ddafde837473c212db8b313 # v5 | ||
| with: | ||
| method: kubeconfig | ||
| kubeconfig: ${{ secrets.KUBECONFIG }} | ||
|
|
||
| - name: Deploy to Kubernetes | ||
| uses: Azure/k8s-deploy@v6 | ||
| uses: Azure/k8s-deploy@c7ebd0d5f39477a23f1b5dea0f52e6db04adf28e # v6 | ||
| with: | ||
| namespace: web | ||
| manifests: | | ||
| infra/kubernetes/namespaces/web/site/deployment.yaml | ||
| images: 'ghcr.io/python-discord/site:${{ inputs.sha-tag }}' | ||
|
|
||
| - name: Purge Cloudflare Edge Cache | ||
| uses: jakejarvis/cloudflare-purge-action@master | ||
| uses: jakejarvis/cloudflare-purge-action@eee6dba0236093358f25bb1581bd615dc8b3d8e3 # master | ||
| env: | ||
| CLOUDFLARE_ZONE: 989c984a358bfcd1e9b9d188cc86c1df | ||
| CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ jobs: | |
| 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 | ||
| 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 | ||
| curl -sSL -H "Authorization: token $GITHUB_TOKEN" -o pull_request_payload.zip $DOWNLOAD_URL || exit 2 | ||
|
|
@@ -36,13 +36,14 @@ jobs: | |
| echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_EVENT_WORKFLOW_RUN_ARTIFACTS_URL: ${{ github.event.workflow_run.artifacts_url }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does using an environment variable improve our security posture?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good morning Mark, using an environment variable improves our security posture because it cements Python Discord's commitment to the environment. In times of massive energy expenditure by LLMs, it is important for us to make a statement on how we love the environment. In other words, I have no idea. |
||
|
|
||
| # 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 | ||
| uses: SebastiaanZ/github-status-embed-for-discord@67f67a60934c0254efd1ed741b5ce04250ebd508 # v0.3.0 | ||
| with: | ||
| # Our GitHub Actions webhook | ||
| webhook_id: '784184528997842985' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GOOD change!