Skip to content
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

Add a GCS deploy workflow #45

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/deploy-to-gcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy repository to GCS

on:
workflow_call:
inputs:
gcp_workload_identity_provider:
required: true
type: string
gcp_service_account:
required: true
type: string

permissions: {}

jobs:
deploy-to-gcs:
runs-on: ubuntu-latest
permissions:
id-token: 'write' # For authenticating with the GitHub workflow identity

steps:
- uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: github-pages

- name: Prepare data for upload
run: |
# Extract the github-pages arcive into ./repository/
mkdir repository
tar --directory repository -xvf artifact.tar

- uses: google-github-actions/auth@a6e2e39c0a0331da29f7fd2c2a20a427e8d3ad1f # v2.1.1
with:
token_format: access_token
workload_identity_provider: ${{ inputs.gcp_workload_identity_provider }}
jku marked this conversation as resolved.
Show resolved Hide resolved
service_account: ${{ inputs.gcp_service_account }}

- uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
with:
project_id: projectsigstore-staging

- name: Upload repository to GCS
run: |
BUCKET="gs://tuf-root-staging/"
LOAD_BALANCER="tuf-repo-cdn-lb"

# Upload metadata, make sure we upload timestamp last
gcloud storage rsync --cache-control=no-store --recursive --exclude=timestamp.json \
repository/ $BUCKET
gcloud storage cp --cache-control=no-store repository/timestamp.json $BUCKET

jku marked this conversation as resolved.
Show resolved Hide resolved
# invalidate CDN cache
gcloud compute url-maps invalidate-cdn-cache $LOAD_BALANCER --path "/*" --async
11 changes: 10 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ jobs:
id-token: 'write' # for signing with the GitHub Actions workflow identity
uses: ./.github/workflows/test.yml

deploy-to-gcs:
needs: [test-deployed-repository]
permissions:
id-token: 'write' # for authenticating with OIDC
uses: ./.github/workflows/deploy-to-gcs.yml
jku marked this conversation as resolved.
Show resolved Hide resolved
with:
gcp_workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
gcp_service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}

update-issue:
runs-on: ubuntu-latest
needs: [build, deploy-to-pages, test-deployed-repository]
needs: [build, deploy-to-pages, test-deployed-repository, deploy-to-gcs]
if: always() && !cancelled()
permissions:
issues: 'write' # for modifying Issues
Expand Down