Skip to content

Commit

Permalink
Support for building PR previews with secrets (ProjectPythia#108)
Browse files Browse the repository at this point in the history
* Support for building PR previews with secrets

* Remove cruft
  • Loading branch information
brian-rose authored Jun 23, 2023
1 parent d2c3c3c commit b1f70f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 68 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/secret-book-build.yaml

This file was deleted.

41 changes: 3 additions & 38 deletions .github/workflows/trigger-book-build.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
name: trigger-book-build
on:
pull_request:
env:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}

# instead of calling build-book directly, we will create and upload an artifact containing the source (minus .github directory)

jobs:
get-code:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3

- name: Remove .github directory
id: remove_directory
run: |
rm -rf .github/
- name: Zip the code
run: |
set -x
set -e
if [ -f pr_code.zip ]; then
rm -rf pr_code.zip
fi
zip -r pr_code.zip .
- name: Upload zipped code artifact
uses: actions/upload-artifact@v3
with:
name: code-zip-${{ github.event.number }}
path: ./pr_code.zip
# build:
# uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
# secrets:
# ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
# ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}
# with:
# environment_name: radar-cookbook-dev
# artifact_name: book-zip-${{ github.event.number }}
# # Other input options are possible, see ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml
uses: ProjectPythia/cookbook-actions/.github/workflows/get-code.yaml@main
with:
code_artifact_name: code-zip-${{ github.event.number }}
23 changes: 20 additions & 3 deletions .github/workflows/trigger-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,35 @@ on:
types:
- requested
- completed

env:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}

jobs:
find-pull-request:
uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main
deploy-preview:

build-book-for-preview:
needs: find-pull-request
if: github.event.workflow_run.conclusion == 'success'
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
secrets:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}
with:
environment_name: radar-cookbook-dev
artifact_name: book-zip-${{ needs.find-pull-request.outputs.number }}
build_from_code_artifact: "true"
code_artifact_name: code-zip-${{ needs.find-pull-request.outputs.number }}

deploy-preview:
needs: build-book-for-preview
if: github.event.workflow_run.conclusion == 'success'
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
with:
artifact_name: book-zip-${{ needs.find-pull-request.outputs.number }}
destination_dir: _preview/${{ needs.find-pull-request.outputs.number }} # deploy to subdirectory labeled with PR number
is_preview: 'true'
is_preview: 'false' # it is a preview but deployed from main branch context

preview-comment:
needs: find-pull-request
Expand Down

0 comments on commit b1f70f5

Please sign in to comment.