🎥 Make videos programmatically with React
create gcp build pipeline
Matt McGillivray8178bc24a185
diff --git a/.github/workflows/deploy-gcp-artifact.yml b/.github/workflows/deploy-gcp-artifact.ymlnew file mode 100644index 0000000000..7430641959--- /dev/null+++ b/.github/workflows/deploy-gcp-artifact.yml@@ -0,0 +1,86 @@+name: Deploy GCP artifact+run-name: Deploy latest release as an artifact in GCP Artifact Registry+on:+ workflow_dispatch:+jobs:+ gcp-artifact-upload:+ runs-on: ubuntu-latest++ permissions:+ contents: "read"+ id-token: "write"++ steps:+ - id: checkout+ name: Checkout+ uses: actions/checkout@main++ - uses: actions/setup-node@v3+ with:+ node-version: ${{ matrix.node_version }}+ - uses: actions-rs/toolchain@v1+ with:+ profile: minimal+ toolchain: stable+ override: true+ - run: |+ corepack enable+ - uses: Iamshankhadeep/[email protected]+ with:+ token: ${{ secrets.GITHUB_TOKEN }}+ version: ${{ matrix.ffmpeg_version }}++ - name: Cache .pnpm-store+ uses: actions/[email protected]+ with:+ path: ~/.pnpm-store+ key: v2-deps-${{ runner.os }}-node${{ matrix.node_version }}++ - name: Cache node_modules/.cache+ uses: actions/[email protected]+ with:+ path: node_modules/.cache+ key: v2-deps-${{ runner.os }}-${{ matrix.ffmpeg_version }}-node${{ matrix.node_version }}-v2+ - name: Install+ run: pnpm install --frozen-lockfile+ - name: Cache dist/ folders+ uses: actions/[email protected]+ if: runner.os != 'windows'+ with:+ path: packages/**/dist+ key: dist-${{ runner.os }}-${{ matrix.ffmpeg_version }}-node${{ matrix.node_version }}-v2-bust++ - name: get remotion version+ id: version+ uses: notiz-dev/github-action-json-property@release+ with:+ path: "packages/gcp/container/package.json"+ prop_path: "version"++ - run: echo version pulled from package.json":" "${{ steps.version.outputs.prop }}"++ - id: auth+ name: Authenticate with Google Cloud+ uses: google-github-actions/auth@v1+ with:+ token_format: access_token+ workload_identity_provider: projects/1079363441639/locations/global/workloadIdentityPools/github-id-pool/providers/github-provider+ service_account: [email protected]+ access_token_lifetime: 300s++ - name: Login to Artifact Registry+ uses: docker/login-action@v2+ with:+ registry: us-docker.pkg.dev+ username: oauth2accesstoken+ password: ${{ steps.auth.outputs.access_token }}++ - id: docker-push-tagged+ name: Tag Docker image and push to Google Artifact Registry+ uses: docker/build-push-action@v4+ with:+ context: packages/gcp/container+ push: true+ tags: |+ us-docker.pkg.dev/remotion-dev/cloud-run/render:${{ steps.version.outputs.prop }}+ us-docker.pkg.dev/remotion-dev/cloud-run/render:latestdiff --git a/packages/gcp/container/readme.md b/packages/gcp/container/readme.mdindex 378b34b054..eb10653a03 100644--- a/packages/gcp/container/readme.md+++ b/packages/gcp/container/readme.md@@ -12,7 +12,88 @@ The Dockerfile also bundles chromium and ffmpeg, and installs the [functions-fraThe Artifact Regsitry in GCP is a place to store container images. The Remotion-dev project has been created in GCP as a central place to host a public registry which can be read from by anyone. In particular, it is read from in the [Remotion GCP API when deploying a new Cloud Run instance](../src/api/deploy-new-cloud-run.ts). The image that is retrieved is located at `us-docker.pkg.dev/remotion-dev/cloud-run/render:${remotionVersion}` where remotionVersion is a prop that gets passed in. Therefore, whenever a new version of Remotion is released, a new image needs to be added to the Artifact Registry that makes use of the latest Remotion Package. The images are tagged with the Remotion version, so that people can get the required version for their environment.-## [For now] Manual Upload to Artifact Registry+## Build Pipeline++A Github Action Workflow has been created under the file `deploy-gcp-artifact.yml`. It authenticates with GCP using a service account in the remotion-dev project ([email protected]) using a workload identity pool. The service account has write permissions on the Artifact Registry repository that contains Cloud Run images. The workflow logs in to Artifact Registry, and uploads a new image, tagging it with the latest Release tag from GitHub, as well as tagging it with 'latest'. Subsequent images will take the 'lastest' tags for themselves, and only one image will have this tag at a time. This workflow will only run when a Release is published or edited in GitHub.++### Steps taken to allow Github Action to work with GCP++This pipeline should work as is, but the steps are recorded here for future troubleshooting if necessary.++1. Created a new service account, called github-action, whose purpose is to run the github action.+ ```+ gcloud iam service-accounts create github-action \+ --project remotion-dev+ ```+2. Enabled IAM API in the project++ ```+ gcloud services enable iamcredentials.googleapis.com \+ --project remotion-dev+ ```++3. Created a workload identity pool called github-id-pool++ ```+ gcloud iam workload-identity-pools create github-id-pool \+ --project=remotion-dev \+ --location="global" \+ --display-name=github-id-pool++ ```++4. Received a unique identifier for this pool++ ```+ gcloud iam workload-identity-pools describe github-id-pool \+ --project=remotion-dev \+ --location="global" \+ --format="value(name)"++ ```++5. Created a provider within the pool for github to access++ ```+ gcloud iam workload-identity-pools providers create-oidc github-provider \+ --project=remotion-dev \+ --location="global" \+ --workload-identity-pool=github-id-pool \+ --display-name=github-provider \+ --attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository" \+ --issuer-uri="https://token.actions.githubusercontent.com"+ ```++6. Allow the GitHub Action based in the remotion repository to login to the service account via the provider.++ ```+ gcloud iam service-accounts add-iam-policy-binding "[email protected]" \+ --project=remotion-dev \+ --role="roles/iam.workloadIdentityUser" \+ --member="principalSet://iam.googleapis.com/projects/1079363441639/locations/global/workloadIdentityPools/github-id-pool/attribute.repository/remotion-dev/remotion"+ ```++ **Note for Jonny: For now I have also given access to my personal repo**++7. This command returns the identifier of that provider++ ```+ gcloud iam workload-identity-pools providers describe github-provider \+ --project=remotion-dev \+ --location="global" \+ --workload-identity-pool=github-id-pool \+ --format="value(name)"+ ```++8. Allow the newly created Service Account to access the Artifact Registry in the remotion-dev project++ ```+ gcloud projects add-iam-policy-binding remotion-dev \+ --member="serviceAccount:[email protected]" \+ --role="roles/artifactregistry.writer"+ ```++## Backup - Manual Upload to Artifact RegistryComplete a build for the GCP package, so that `gcp/container` contains an up-to-date `dist` folder.@@ -25,7 +106,3 @@ Complete a build for the GCP package, so that `gcp/container` contains an up-to-4. Run `gcloud builds submit --tag us-docker.pkg.dev/remotion-dev/cloud-run/render:VERSION` replacingVERSION with the current Remotion version.5. Navigate to [Artifact Registry](https://console.cloud.google.com/artifacts/docker/remotion-dev/us/cloud-run/render?project=remotion-dev) to see the new image, with the correct tag.--## [Future] Build Pipeline--The github build pipeline will need to be edited to build the Dockerfile, tag it with the version number and upload it to Google Artifact Registry. [This looks like a good starting point](https://gist.github.com/palewire/12c4b2b974ef735d22da7493cf7f4d37)diff --git a/packages/gcp/readme.md b/packages/gcp/readme.mdindex 5792b86990..5dae5217bc 100644--- a/packages/gcp/readme.md+++ b/packages/gcp/readme.md@@ -165,3 +165,8 @@ To render media, send a POST request to the URL with the following body:- sprinkle quietFlagProvided() throughout- time for uploading to GCP Storage Bucket is always 0ms- add LS, RM, RMALL subcommands++### Render command++- Create API that just makes a post request to Cloud Run, to perform render+- Use lambda one for inspiration