Repository navigation
chore: harden GitHub Actions for platform compliance #785
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cb2e8c5
chore: harden GitHub Actions for platform compliance
kridai 4c96e26
chore: update LICENSE year so LicenseTest passes
kridai 2f8ed05
fix: replace docker/login-action with CLI login
kridai 38ba143
test: vendor the Prism mock server used by make test-docker (#786)
kridai 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| - package-ecosystem: "maven" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
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 |
|---|---|---|
|
|
@@ -13,23 +13,27 @@ on: | |
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| runs-on: ubuntu-x64 | ||
| if: github.repository_owner == 'sendgrid' | ||
| timeout-minutes: 20 | ||
| permissions: | ||
| contents: read | ||
| strategy: | ||
| matrix: | ||
| java: [ 8, 11 ] | ||
| env: | ||
| DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }} | ||
| steps: | ||
| - name: Checkout sendgrid-java | ||
| uses: actions/checkout@v2 | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| # Plain CLI login: docker/login-action is not on this org's action allowlist. | ||
| - name: Login to Docker Hub | ||
| if: env.DOCKER_LOGIN | ||
| uses: docker/login-action@v1 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_AUTH_TOKEN }} | ||
| env: | ||
| DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
| DOCKER_AUTH_TOKEN: ${{ secrets.DOCKER_AUTH_TOKEN }} | ||
| run: echo "$DOCKER_AUTH_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
|
||
| - name: Install Docker Compose | ||
| run: | | ||
|
|
@@ -41,17 +45,22 @@ jobs: | |
|
|
||
| deploy: | ||
| name: Deploy | ||
| if: success() && github.ref_type == 'tag' | ||
| if: success() && github.ref_type == 'tag' && github.repository_owner == 'sendgrid' | ||
| needs: [ test ] | ||
| runs-on: ubuntu-latest | ||
| runs-on: ubuntu-x64 | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout sendgrid-java | ||
| uses: actions/checkout@v2 | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| # The release action verifies refs/tags/<tag> in the local clone. | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Sonatype Maven | ||
| uses: actions/setup-java@v2 | ||
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | ||
| with: | ||
| java-version: 8 | ||
| java-version: '8' | ||
| distribution: temurin | ||
| server-id: central | ||
| server-username: MAVEN_USERNAME | ||
|
|
@@ -63,12 +72,11 @@ jobs: | |
| run: make install | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: sendgrid/dx-automator/actions/release@main | ||
| uses: twilio/sdk-actions/github-release@9b1c3222c9ffe38aadedb11c5b9f5a172b5e9951 # v1 | ||
|
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. fyi- the changelog generation is different in |
||
| with: | ||
| assets: sendgrid-java.jar | ||
| footer: '**[Maven](https://mvnrepository.com/artifact/com.sendgrid/sendgrid-java/${version})**' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| changelog-file: CHANGELOG.md | ||
| footer: '**[Maven](https://mvnrepository.com/artifact/com.sendgrid/sendgrid-java/${{ github.ref_name }})**' | ||
|
|
||
| - name: Publish to Maven | ||
| env: | ||
|
|
@@ -77,25 +85,25 @@ jobs: | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| run: mvn clean deploy -DskipTests=true -B -U -Prelease | ||
|
|
||
| - name: Submit metric to Datadog | ||
| uses: sendgrid/dx-automator/actions/datadog-release-metric@main | ||
| env: | ||
| DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} | ||
| # - name: Submit metric to Datadog | ||
| # uses: sendgrid/dx-automator/actions/datadog-release-metric@08b601b726671445abc798ed59881766ec8fefc6 # main | ||
| # env: | ||
| # DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} | ||
|
|
||
| notify-on-failure: | ||
| name: Slack notify on failure | ||
| if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') | ||
| needs: [ test, deploy ] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: rtCamp/action-slack-notify@v2 | ||
| env: | ||
| SLACK_COLOR: failure | ||
| SLACK_ICON_EMOJI: ':github:' | ||
| SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} | ||
| SLACK_TITLE: Action Failure - ${{ github.repository }} | ||
| SLACK_USERNAME: GitHub Actions | ||
| SLACK_MSG_AUTHOR: twilio-dx | ||
| SLACK_FOOTER: Posted automatically using GitHub Actions | ||
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
| MSG_MINIMAL: true | ||
| # notify-on-failure: | ||
| # name: Slack notify on failure | ||
| # if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') | ||
| # needs: [ test, deploy ] | ||
| # runs-on: ubuntu-x64 | ||
| # steps: | ||
| # - uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 | ||
| # env: | ||
| # SLACK_COLOR: failure | ||
| # SLACK_ICON_EMOJI: ':github:' | ||
| # SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} | ||
| # SLACK_TITLE: Action Failure - ${{ github.repository }} | ||
| # SLACK_USERNAME: GitHub Actions | ||
| # SLACK_MSG_AUTHOR: twilio-dx | ||
| # SLACK_FOOTER: Posted automatically using GitHub Actions | ||
| # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
| # MSG_MINIMAL: true | ||
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Prism mock of the SendGrid v3 API, used by `make test-docker`. | ||
| # Everything is pinned: the base image by digest, the Prism binary by sha256, | ||
| # and the spec is vendored (see README.md in this directory). | ||
| FROM debian:bookworm-slim@sha256:7c7b2c966bc9ee8cedfeef67e0e279108992c77681fa595db4a9d65c06ccc587 | ||
|
|
||
| ARG PRISM_VERSION=v2.0.17 | ||
| ARG PRISM_SHA256=80f37c2aedab2035a20e6025ac552908bce9e5d64a9338a48434e604e5590731 | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends curl ca-certificates \ | ||
| && curl -fsSL "https://github.com/stoplightio/prism/releases/download/${PRISM_VERSION}/prism_linux_amd64" -o /usr/local/bin/prism \ | ||
| && echo "${PRISM_SHA256} /usr/local/bin/prism" | sha256sum -c - \ | ||
| && chmod +x /usr/local/bin/prism \ | ||
| && apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY oai_stoplight.json /oai_stoplight.json | ||
|
|
||
| EXPOSE 4010 | ||
| CMD ["prism", "--port", "4010", "mock", "--spec", "/oai_stoplight.json"] |
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Mock SendGrid API for tests | ||
|
|
||
| `make test-docker` runs the test suite against a local mock of `api.sendgrid.com`: | ||
|
|
||
| - **prism**: [Prism](https://github.com/stoplightio/prism) v2.0.17 mocking `oai_stoplight.json`. | ||
| The binary's sha256 is checked in `Dockerfile.prism`. | ||
| - **nginx**: answers TLS as `api.sendgrid.com` with the self-signed test certificate in | ||
| `nginx/` and proxies to prism. The certificate and key exist only for this mock. | ||
| - **helper-runner**: the repo's root `Dockerfile`, which trusts that certificate and runs | ||
| `make test-integ`. | ||
|
|
||
| `oai_stoplight.json` is vendored from `sendgrid/sendgrid-oai` at commit | ||
| `eb7a825bf06dfec7da2622735c5334c0d35da9fa`, the same commit the previous | ||
| remote `prism-java.sh` script pinned. These files used to be downloaded at test time | ||
| from that repository, which is no longer publicly readable. |
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Runs the test suite against a local mock of api.sendgrid.com: | ||
| # helper-runner -> nginx (TLS as api.sendgrid.com) -> prism (mock of the v3 spec) | ||
| services: | ||
| helper-runner: | ||
| build: | ||
| context: .. | ||
| args: | ||
| - version=${version:-8} | ||
| command: make test-integ | ||
| depends_on: | ||
| nginx: | ||
| condition: service_healthy | ||
| nginx: | ||
| image: nginx:1.27-alpine@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10 | ||
| networks: | ||
| default: | ||
| aliases: | ||
| - api.sendgrid.com | ||
| volumes: | ||
| - ./nginx:/etc/nginx:ro | ||
| depends_on: | ||
| - prism | ||
| healthcheck: | ||
| # 2xx-4xx means nginx is up and prism answered; 502 means prism isn't ready yet. | ||
| test: ["CMD-SHELL", "wget -S -O /dev/null http://127.0.0.1/ 2>&1 | grep -qE '^ HTTP/1\\.[01] [1-4][0-9][0-9]'"] | ||
| interval: 2s | ||
| timeout: 2s | ||
| retries: 30 | ||
| prism: | ||
| platform: linux/amd64 | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.prism |
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIIDyDCCArACCQDoRrX2g0xuUDANBgkqhkiG9w0BAQsFADCBpDELMAkGA1UEBhMC | ||
| VVMxEzAR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u6mIBHfiBgtWaMhhAjaFA0ALAsJa/8WmAgUfb5V | ||
| dR73oc1GJtDTKJgZ3cFaKAaimDIxJNHSjpYADCEkdKoVv1b/JxD8JEzI9NmrU5xd | ||
| 7T7pG6RVT4xO5flCJM+nO851jUaKVmcKD7lhQe9Z8P0bH+ecFyQDILbOFd8ojBHV | ||
| 6hSLw4vZCM5bR7iOFBUYzxaKcXl6FJTKaYXD/UrfFXA95YZieGPKYxoF6AkB0I1C | ||
| 9RcmCQkkJZnCRCJX | ||
| -----END CERTIFICATE----- |
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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| -----BEGIN PRIVATE KEY----- | ||
| MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCZL3FDgPX2NDZj | ||
| K4XM3vOT3FFZ46KXtvOQ6SAUIKqWE8LO5iUyqAPUXsiZw2hdsXDXezyT/XzFarEH | ||
| KcWC2aeK4Wb9/iDyIB94GffmLWDcF/Rukb2BafqH91fdhduDSeXR75sxAbi4PSBx | ||
| zJID9W3pjpOyGC7qlWj7IyJYSpBFrS2CqvZZnw1TRs6ulDNT1s6u8rGta92YjEhg | ||
| 6am3LBNdbe8uLrcukTaLLl09YU7gkJEFzTZdnzgHkSFt9W2iM1sV21bq6u39WStZ | ||
| u3XxsVyh4zfDr8dtrwwX7Pw41LxCMP0JFeV40oMxUua8SZYvRHE7gfU/c7tqv+89 | ||
| p8QOhs8ZAgMBAAECggEASPrwVD/Bbu3LJ44ZrdReaYhifZfU48D244gdj1lMzDlX | ||
| 62h8OlkPkgMiQRd2xoR+BTsiTkNLSWaeNpJxFfkKOEFQ5xtGqPQi6f49O71M0y7a | ||
| dj8a8OgDwvlVNCXMwgzX4B/uaPewAJ6msXDL8/Tey5Hwzb11xK8wF83SVAwaFgdB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+IyL3Z/PHUusO51S+rNGPyKr63TXYI | ||
| Ucx/inqVBb7oeKlSHYmA1w== | ||
| -----END PRIVATE KEY----- |
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.
maybe verify after merge if dependabot even executes?