Skip to content

demo fix

demo fix #1

Workflow file for this run

name: Deploy Preevy environment
on:
pull_request:
types:
- opened
- reopened
- synchronize
permissions:
id-token: write
contents: read
pull-requests: write
concurrency: preevy-${{ github.event.number }}
jobs:
deploy:
timeout-minutes: 15
environment:
name: pr-${{ github.event.number }}
url: ${{ fromJson(steps.preevy_up.outputs.urls-map).frontend[3000] }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Authenticate to Google Cloud'
id: gcloud_auth
uses: 'google-github-actions/auth@v1'
with:
token_format: access_token
credentials_json: '${{ secrets.PREEVY_SA_KEY }}'
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: me-west1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcloud_auth.outputs.access_token }}
# required by imjasonh/gke-auth
- uses: actions/setup-go@v4
with:
go-version: 1.18
# this is a lot faster than installing gcloud and gke-gcloud-auth-plugin
- uses: imjasonh/gke-auth@v0.2.0
with:
project: ${{ vars.GOOGLE_CLOUD_PROJECT }}
location: ${{ vars.GOOGLE_CLOUD_KUBE_CLUSTER_LOCATION }}
cluster: ${{ vars.GOOGLE_CLOUD_KUBE_CLUSTER_NAME }}
# use a preexisting kubernetes builder which already has cached layers
- name: Find pod of existing kubernetes builder
id: find_pod
run: |
pod=$(kubectl get pod --selector=app='${{ vars.GOOGLE_CLOUD_KUBE_CLUSTER_BUILDER }}' -o jsonpath='{.items[0].metadata.name}')
echo "pod=${pod}" >> $GITHUB_OUTPUT
- name: Configure buildx to use the existing kubernetes builder
id: buildx_setup
uses: docker/setup-buildx-action@v3
with:
driver: remote
# https://github.com/moby/buildkit/tree/master/examples/kubernetes#pod
# uses the kube-pod connection helper: https://github.com/moby/buildkit/pull/951
endpoint: kube-pod://${{ steps.find_pod.outputs.pod }}
- name: Deploy Preevy environment
id: preevy_up
uses: livecycle/preevy-up-action@v2.3.0
with:
install: 'gh-release'
profile-url: ${{ vars.PREEVY_PROFILE_URL }}
args: "--driver kube-pod --registry '${{ vars.GOOGLE_CLOUD_REGISTRY }}' --builder '${{ steps.buildx_setup.outputs.name }}'"
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Link environment to livecycle
env:
LIVECYCLE_API_KEY: ${{ secrets.LIVECYCLE_API_KEY }}
PREVIEW_URL: ${{ fromJson(steps.preevy_up.outputs.urls-map).frontend[3000] }}
run: npx @livecycle/cli link --url=$PREVIEW_URL --from-git=. --api-key=$LIVECYCLE_API_KEY