Skip to content

Commit

Permalink
Update master-pr-gae.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdrosas87 authored Nov 14, 2023
1 parent af77a94 commit 04ac871
Showing 1 changed file with 3 additions and 66 deletions.
69 changes: 3 additions & 66 deletions .github/workflows/master-pr-gae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,12 @@ jobs:
build-push-deploy:
name: 'Build and Deploy PR Preview to Integration'
runs-on: ubuntu-latest
if: ${{ (github.event.action != 'closed') && (startsWith(github.head_ref, 'preview') == true) }}
if: ${{ (github.event.action != 'closed') }}

# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v2

# gcloud CLI setup
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}
project_id: edc-int-6c5e
export_default_credentials: true

- name: Get app.yaml
run: gcloud secrets versions access latest --secret=rubin-obs-api-appyaml > app.yaml

- name: Format version name
id: version_name
run: echo "version_name=$(echo \"${{ github.head_ref }}\" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Deploy to App Engine
env:
BRANCH_NAME: ${{ env.version_name }}
run: |
gcloud app deploy app.yaml \
--no-promote \
--version=${BRANCH_NAME,,}
# Create or update a comment with the URL
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: A preview of this PR

- name: Create or update a comment with the URL to the PR
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
A preview of this PR will be available at https://${{ github.head_ref }}-dot-rubin-obs-api-int-dot-edc-int-6c5e.uc.r.appspot.com/ until the request is closed. :sparkles:
reactions: '+1'
edit-mode: replace

cleanup:
name: 'Cleanup PR Preview'
runs-on: ubuntu-latest
if: ${{ (github.event.action == 'closed') && (startsWith(github.head_ref, 'preview') == true) }}

# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v2

# gcloud CLI setup
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}
project_id: edc-int-6c5e
export_default_credentials: true

# Destruct!
- name: Destroy version
env:
BRANCH_NAME: ${{ env.version_name }}
run: gcloud app versions delete ${BRANCH_NAME,,} --service=rubin-obs-api
- name: Dump secret
run: echo -n "${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }}" | xxd -ps

0 comments on commit 04ac871

Please sign in to comment.