feat(DEV-11582): deploy preview #31
This file contains 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 is used to deploy the application to Pull Preview. | |
# See: https://github.com/pullpreview/action/wiki/Getting-Started | |
name: Pull Preview Deploy | |
on: | |
pull_request: | |
types: [labeled, unlabeled, synchronize, closed, reopened] | |
jobs: | |
deploy: | |
environment: deploypreview # todo::unify names to 'pull-preview' | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
deployments: write # to delete deployments | |
pull-requests: write # to remove labels | |
statuses: write # to create commit status | |
name: deploy | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_HOST }} | |
username: ${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_USERNAME }} | |
password: ${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_TOKEN_RW }} | |
- name: Create Image Full Name | |
run: echo "preview_sdk_demo_with_nextjs_and_clerk_auth_image=${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_HOST }}/${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_REPOSITORY }}/preview-sdk-demo-with-nextjs-and-clerk-auth:${{ github.sha }}" >> "$GITHUB_ENV" | |
- name: Get Turborepo service container IP | |
run: | | |
echo "turbo_api_ip=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')" >> "$GITHUB_ENV" | |
- uses: actions/checkout@v4 | |
- name: Run Turborepo Remote Cache | |
uses: dtinth/[email protected] | |
- name: Build and push Image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ${{ env.preview_sdk_demo_with_nextjs_and_clerk_auth_image }} | |
file: SdkDemoWithNextjsAndClerkAuth.PullPreviewDeploy.Dockerfile | |
platform: linux/amd64 | |
secrets: | | |
"clerk_publishable_key=${{ vars.PULL_PREVIEW_CLERK_PUBLISHABLE_KEY_DEV }}" | |
"clerk_secret_key=${{ secrets.PULL_PREVIEW_CLERK_SECRET_KEY_DEV }}" | |
"clerk_webhook_signing_secret=${{ secrets.PULL_PREVIEW_CLERK_WEBHOOK_SIGNING_SECRET_DEV }}" | |
"monite_project_client_secret=${{ secrets.PULL_PREVIEW_MONITE_PROJECT_CLIENT_SECRET_DEV }}" | |
"monite_project_client_id=${{ secrets.PULL_PREVIEW_MONITE_PROJECT_CLIENT_ID_DEV }}" | |
build-args: | | |
APP_SIGN_IN_URL=https://${{ vars.PULL_PREVIEW_CLERK_DOMAIN_DEV }}/sign-in | |
TURBO_API=http://${{ env.turbo_api_ip }}:41230 | |
TURBO_TEAM=turbogha | |
TURBO_TOKEN=turbogha | |
cache-to: type=registry,ref=${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_HOST }}/${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_REPOSITORY }}/preview-sdk-demo-with-nextjs-and-clerk-auth:buildcache,mode=min | |
cache-from: type=registry,ref=${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_HOST }}/${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_REPOSITORY }}/preview-sdk-demo-with-nextjs-and-clerk-auth:buildcache | |
env: | |
SOURCE_DATE_EPOCH: 0 | |
- name: Update docker-compose.pull-preview.yml | |
run: | | |
sed -i "s|\${PREVIEW_SDK_DEMO_WITH_NEXTJS_AND_CLERK_AUTH_IMAGE}|${{ env.preview_sdk_demo_with_nextjs_and_clerk_auth_image }}|g" docker-compose.pull-preview.yml | |
- uses: pullpreview/action@v5 | |
# see https://github.com/pullpreview/action/wiki/Inputs | |
with: | |
admins: radist2s,nekedos | |
compose_files: docker-compose.pull-preview.yml | |
instance_type: small | |
registries: docker://${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_USERNAME }}:${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_TOKEN_RO }}@${{ secrets.PULL_PREVIEW_DOCKER_REGISTRY_HOST }} | |
env: | |
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
AWS_REGION: "eu-central-1" # Frankfurt, Zone A |