Skip to content
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

PREview update for improved stability #10

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/actions/PREview-data/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ outputs:
runs:
using: "composite"
steps:
- name: Determine branch shortname, bucket name and URL.
id: data
shell: bash
run: |
BRANCH=`echo ${GITHUB_HEAD_REF} | sed 's/.*\///'`
echo "::set-output name=branch::${BRANCH}"
echo "::set-output name=bucket::mondoo-pre-docs-${BRANCH}/docs"
echo "::set-output name=url::https://mondoo-pre-docs-${BRANCH}.storage.googleapis.com/docs/index.html"
- name: Determine branch shortname and bucket name
shell: bash
run: |
BRANCH=`echo ${GITHUB_HEAD_REF} | sed 's/.*\///'`
BRANCH=`echo ${GITHUB_HEAD_REF} | cksum | cut -d" " -f1` # Use checksum of branch name to avoid invalid bucket names
echo BRANCH=${BRANCH} >> $GITHUB_ENV
echo BUCKET=mondoo-pre-docs-${BRANCH} >> $GITHUB_ENV
echo URL=https://mondoo-pre-docs-${BRANCH}.storage.googleapis.com/docs/index.html >> $GITHUB_ENV
Expand Down
30 changes: 7 additions & 23 deletions .github/workflows/PREview-create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,32 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true

data:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.data.outputs.branch }}
bucket: ${{ steps.data.outputs.bucket }}
url: ${{ steps.data.outputs.url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine branch shortname, bucket name and URL.
id: data
shell: bash
run: |
BRANCH=`echo ${GITHUB_HEAD_REF} | sed 's/.*\///'`
echo "::set-output name=branch::${BRANCH}"
echo "::set-output name=bucket::mondoo-pre-docs-${BRANCH}/docs"
echo "::set-output name=url::https://mondoo-pre-docs-${BRANCH}.storage.googleapis.com/docs/index.html"
env

build:
uses: ./.github/workflows/_build.yaml
with:
output_dir: build
secrets: inherit

deploy-update:
needs: [data, build]
needs: [build]
uses: ./.github/workflows/_deploy.yaml
with:
src_dir: build
bucket: ${{ needs.data.outputs.bucket }}
secrets: inherit

notify:
runs-on: ubuntu-latest
needs: [deploy-update, data]
needs: [deploy-update]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Obtain Bucket Name
uses: ./.github/actions/PREview-data
- uses: mshick/add-pr-comment@v2
if: success()
continue-on-error: true
with:
message: |
**PREview has been updated at ${{ needs.data.outputs.url }}**
**PREview has been updated at ${{ env.URL }}**
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
1 change: 1 addition & 0 deletions .github/workflows/PREview-delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- uses: mshick/add-pr-comment@v2
continue-on-error: true
with:
message: |
**Cleaning up PREview environment...**
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/PREview-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,32 @@ on:
types: [synchronize]

jobs:
data:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.data.outputs.branch }}
bucket: ${{ steps.data.outputs.bucket }}
url: ${{ steps.data.outputs.url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine branch shortname, bucket name and URL.
id: data
shell: bash
run: |
BRANCH=`echo ${GITHUB_HEAD_REF} | sed 's/.*\///'`
echo "::set-output name=branch::${BRANCH}"
echo "::set-output name=bucket::mondoo-pre-docs-${BRANCH}/docs"
echo "::set-output name=url::https://mondoo-pre-docs-${BRANCH}.storage.googleapis.com/docs/index.html"

build:
uses: ./.github/workflows/_build.yaml
with:
output_dir: build
secrets: inherit

deploy-update:
needs: [data, build]
needs: [build]
uses: ./.github/workflows/_deploy.yaml
with:
src_dir: build
bucket: ${{ needs.data.outputs.bucket }}
secrets: inherit

notify:
runs-on: ubuntu-latest
needs: [deploy-update, data]
needs: [deploy-update]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Obtain URL
uses: ./.github/actions/PREview-data
- uses: mshick/add-pr-comment@v2
if: success()
continue-on-error: true
with:
message: |
**PREview has been updated at ${{ needs.data.outputs.url }}**
**PREview has been updated at ${{ env.URL }}**
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
8 changes: 3 additions & 5 deletions .github/workflows/_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
default: "build"
required: false
type: string
bucket:
description: "The GCS Bucket to write to"
required: true
type: string

jobs:
deploy:
Expand All @@ -30,5 +26,7 @@ jobs:
credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
- name: Obtain Bucket Name
uses: ./.github/actions/PREview-data
- name: Upload static content to buckets
run: gsutil -m -h "Cache-control:public, max-age=60" rsync -r -c -C -d ${{ inputs.src_dir }}/ gs://${{ inputs.bucket }}
run: gsutil -m -h "Cache-control:public, max-age=60" rsync -r -c -C -d ${{ inputs.src_dir }}/ gs://${BUCKET}
Loading