-
-
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
Draft
jchristgit
wants to merge
4
commits into
main
Choose a base branch
from
ci-security
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
ci security #1618
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| 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 }} | ||
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
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
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
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
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
| 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? |
||
|
|
||
| # 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' | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!