-
Notifications
You must be signed in to change notification settings - Fork 114
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
Example of deployments previews per pull-request #149
Comments
This may not work out of the box with GitHub actions due to the container image that is used as a tool to post to the PR. This logic could potentially be updated to use another GitHub action. Overall, there are 3 different moving parts in this tutorial:
Prep imageIn order to simplify this a bit, I recommend completing the steps Creating tokens and configurations and Creating a new image for Cloud Build as is. It could be ported over to GitHub actions but you'll really only need to build it once. However to use the image we need to login and push it to GitHub's Container Registry. docker image tag gcr.io/PROJECT_ID/deployment-previews ghcr.io/USERNAME/deployment-previews
docker push ghcr.io/USERNAME/deployment-previews Deploying to Cloud Run via
|
Here's a version of the preview:
needs: deploy
runs-on: ubuntu-latest
container:
image: ghcr.io/YOURUSERNAME/deployment-previews
credentials:
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
steps:
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v0.2.0
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Link revision on pull request
run: |-
python3 /app/check_status.py set --project-id ${{ env.PROJECT_ID }} \
--region ${{ env.REGION }} \
--service ${{ env.SERVICE }} \
--pull-request ${{ github.event.number }} \
--repo-name ${{ github.repository }} \
--commit-sha ${{ github.event.pull_request.head.sha }} Notes:
|
Thanks, I was able to get the build/deploy github action jobs working, but I'm not sure I fully understand what's needed for the I'm confused what is the docker container being referenced in the preview job?
Is that a custom Docker container, I also saw it referenced as:
From what I understand the purpose of that job is to set the Cloud Run preview URL on the github commit via the github Checks API? |
In @averikitsch's comment, she references the container image she built and hosted on the github container registry, so I removed her name and put a placeholder. In the original tutorial you build the container from source and host it under your google cloud project. In the "Prep Image" section of Averi's earlier comment, you tag and push that same image to ghci for use in github actions under your username. Hope this makes sense! |
This is high on the google results, so in case anyone is looking for the original tutorial, it has been moved to here https://github.com/GoogleCloudPlatform/devrel-demos/tree/main/app-dev/cloud-run-deployment-previews |
@giraffesyo Thank you. |
Question
Does this github action support the Google Cloud Run preview deployments per PR, that is supported with google cloud build?
My assumption is it's just a wrapper on the gcloud tooling so I would assume it does?
The text was updated successfully, but these errors were encountered: