summaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorShruti Chaturvedi <66940685+ShrutiC-git@users.noreply.github.com>2023-03-18 06:03:07 +0530
committerGitHub <noreply@github.com>2023-03-18 11:33:07 +1100
commit81ea3107ed981c5013c586a4a3794c6b26e876a3 (patch)
tree53e5b8c0a00ab545215c22085fbb97a181f60db4 /.github
parent5c8bc790ff13b78b26a4d862f86b2d7d2c964960 (diff)
Uffizzi PR: Update Uffizzi Workflows (#2502)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/uffizzi-build.yml16
-rw-r--r--.github/workflows/uffizzi-preview.yml14
2 files changed, 14 insertions, 16 deletions
diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml
index 58c7e5866..4cec3582e 100644
--- a/.github/workflows/uffizzi-build.yml
+++ b/.github/workflows/uffizzi-build.yml
@@ -20,12 +20,12 @@ jobs:
run: echo "UUID_APP_TAG=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata
id: meta
- uses: docker/metadata-action@v3
+ uses: docker/metadata-action@v4
with:
images: registry.uffizzi.com/${{ env.UUID_APP_TAG }}
tags: type=raw,value=60d
- name: Build and Push Image to registry.uffizzi.com ephemeral registry
- uses: docker/build-push-action@v2
+ uses: docker/build-push-action@v3
with:
push: true
context: ./
@@ -60,17 +60,11 @@ jobs:
name: preview-spec
path: docker-compose.rendered.yml
retention-days: 2
- - name: Serialize PR Event to File
- run: |
- cat << EOF > event.json
- ${{ toJSON(github.event) }}
-
- EOF
- name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3
with:
name: preview-spec
- path: event.json
+ path: ${{ github.event_path }}
retention-days: 2
delete-preview:
@@ -79,11 +73,9 @@ jobs:
if: ${{ github.event.action == 'closed' }}
steps:
# If this PR is closing, we will not render a compose file nor pass it to the next workflow.
- - name: Serialize PR Event to File
- run: echo '${{ toJSON(github.event) }}' > event.json
- name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3
with:
name: preview-spec
- path: event.json
+ path: ${{ github.event_path }}
retention-days: 2
diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.yml
index ce8a9c46f..784523877 100644
--- a/.github/workflows/uffizzi-preview.yml
+++ b/.github/workflows/uffizzi-preview.yml
@@ -7,11 +7,11 @@ on:
types:
- completed
-
jobs:
cache-compose-file:
name: Cache Compose File
runs-on: ubuntu-latest
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }}
pr-number: ${{ env.PR_NUMBER }}
@@ -29,6 +29,9 @@ jobs:
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "preview-spec"
})[0];
+ if (matchArtifact === undefined) {
+ throw TypeError('Build Artifact not found!');
+ }
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
@@ -39,16 +42,18 @@ jobs:
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip preview-spec.zip
+
- name: Read Event into ENV
run: |
echo 'EVENT_JSON<<EOF' >> $GITHUB_ENV
cat event.json >> $GITHUB_ENV
- echo 'EOF' >> $GITHUB_ENV
+ echo -e '\nEOF' >> $GITHUB_ENV
- name: Hash Rendered Compose File
id: hash
# If the previous workflow was triggered by a PR close event, we will not have a compose file artifact.
if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
run: echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_ENV
+
- name: Cache Rendered Compose File
if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
uses: actions/cache@v3
@@ -70,7 +75,8 @@ jobs:
name: Use Remote Workflow to Preview on Uffizzi
needs:
- cache-compose-file
- uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2.6.1
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
+ uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2
with:
# If this workflow was triggered by a PR close event, cache-key will be an empty string
# and this reusable workflow will delete the preview deployment.
@@ -81,4 +87,4 @@ jobs:
permissions:
contents: read
pull-requests: write
- id-token: write \ No newline at end of file
+ id-token: write