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

Upstream #17

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
84e265f
Create build-images.yaml
gadkins Oct 6, 2022
559c23f
Added two-stage workflow for forks
gadkins Oct 6, 2022
25d491a
Merge pull request #12 from UffizziCloud/update-workflow
gadkins Oct 6, 2022
c0d68d8
Update build-images.yaml
gadkins Oct 7, 2022
a1d4145
Correct file path
gadkins Oct 7, 2022
0b8e9aa
Merge pull request #13 from UffizziCloud/update-workflow
gadkins Oct 7, 2022
66a456f
Update description for two-stage workflow
gadkins Oct 10, 2022
138390e
Merge pull request #16 from UffizziCloud/update-readme
gadkins Oct 10, 2022
b46f1b5
Fixed typo
gadkins Oct 10, 2022
8e6db6e
Merge pull request #17 from UffizziCloud/update-readme
gadkins Oct 10, 2022
9ce0730
Update README.md
gadkins Oct 10, 2022
9791f67
Merge pull request #19 from UffizziCloud/update-readme
gadkins Oct 10, 2022
d94b493
Consolidate workflow
gadkins Oct 13, 2022
6de856a
Delete build-images.yaml
gadkins Oct 13, 2022
6cbbb0f
Rename workflow
gadkins Oct 13, 2022
58b21fb
Update README.md
gadkins Oct 13, 2022
31b1369
Update README.md
gadkins Oct 13, 2022
b272785
Update registry domain
gadkins Oct 13, 2022
65cb869
fix reusable workflow version to tag.
axisofentropy Oct 18, 2022
a31e675
Use latest release of reusable workflow.
axisofentropy Oct 27, 2022
9b38261
Remove trailing whitespace from README.
axisofentropy Oct 27, 2022
13314f2
Upgrade actions and avoid using deprecated `set-output` command. (#29)
axisofentropy Nov 7, 2022
aadb91b
Update README.md
gadkins Nov 9, 2022
05c97fa
Merge pull request #43 from UffizziCloud/update-readme
gadkins Nov 9, 2022
68a3819
Update README.md
gadkins Nov 9, 2022
3558407
Update README.md
gadkins Nov 9, 2022
091538b
Update README.md
gadkins Nov 9, 2022
688efcf
Merge pull request #44 from UffizziCloud/update-readme
gadkins Nov 9, 2022
0a32203
Update README.md
gadkins Nov 28, 2022
59eb2a1
Added emphasis
gadkins Nov 28, 2022
946adbc
Update reusable workflow.
axisofentropy Mar 2, 2023
6154f9d
Update README.md
gadkins Mar 28, 2023
bf188ee
added option to body-parser
moklidia Apr 26, 2023
5a93966
updated node version
moklidia Apr 26, 2023
4b49d16
fixed the result container restarts
moklidia Apr 26, 2023
31b801e
updated pg version
moklidia Apr 26, 2023
3b76cf6
Merge pull request #89 from UffizziCloud/fix_body_parser
moklidia Apr 26, 2023
0853b7c
Update style.css
moklidia Apr 26, 2023
be83e99
Update style.css
moklidia Apr 26, 2023
21a88ac
Use different workflow major version
moklidia Jul 5, 2023
1a37929
Merge pull request #103 from UffizziCloud/test-v3
moklidia Jul 5, 2023
f211261
Merge branch 'main' into upstream
axisofentropy Aug 15, 2023
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
187 changes: 136 additions & 51 deletions .github/workflows/uffizzi-preview.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Deploy Uffizzi Previews
name: Build Images and Deploy Preview Environment

on:
workflow_run:
workflows:
- Build Images
types:
- completed
pull_request:
types: [opened,reopened,synchronize,closed]


jobs:
cache-compose-file:
Expand All @@ -16,43 +14,129 @@ jobs:
compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }}
pr-number: ${{ env.PR_NUMBER }}
steps:
- name: 'Download artifacts'
# Fetch output (zip archive) from the workflow run that triggered this workflow.
uses: actions/github-script@v6
- name: Checkout git repo
uses: actions/checkout@v3
- name: Generate UUID image name
id: uuid
run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_VOTE }}
tags: type=raw,value=24h
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
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,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip preview-spec.zip
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ./vote

- name: Read Event into ENV
build-worker:
name: Build and Push `worker`
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Generate UUID image name
id: uuid
run: echo "UUID_WORKER=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_WORKER }}
tags: type=raw,value=24h
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ./worker

build-result:
name: Build and Push `result`
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Generate UUID image name
id: uuid
run: echo "UUID_RESULT=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_RESULT }}
tags: type=raw,value=24h
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ./result

build-loadbalancer:
name: Build and Push `loadbalancer`
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Generate UUID image name
id: uuid
run: echo "UUID_LOADBALANCER=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# An anonymous, emphemeral registry built on ttl.sh
images: registry.uffizzi.com/${{ env.UUID_LOADBALANCER }}
tags: type=raw,value=24h
- name: Build and Push Image to Uffizzi Ephemeral Registry
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: ./loadbalancer

render-compose-file:
name: Render Docker Compose File
runs-on: ubuntu-latest
needs:
- build-vote
- build-worker
- build-result
- build-loadbalancer
outputs:
compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }}
compose-file-cache-path: docker-compose.rendered.yml
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Render Compose File
run: |
echo 'EVENT_JSON<<EOF' >> $GITHUB_ENV
cat event.json >> $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
Expand All @@ -62,31 +146,32 @@ jobs:
path: docker-compose.rendered.yml
key: ${{ env.COMPOSE_FILE_HASH }}

- name: Read PR Number From Event Object
id: pr
run: echo "PR_NUMBER=${{ fromJSON(env.EVENT_JSON).number }}" >> $GITHUB_ENV

- name: DEBUG - Print Job Outputs
if: ${{ runner.debug }}
run: |
echo "PR number: ${{ env.PR_NUMBER }}"
echo "Compose file hash: ${{ env.COMPOSE_FILE_HASH }}"
cat event.json

deploy-uffizzi-preview:
name: Use Remote Workflow to Preview on Uffizzi
needs:
- cache-compose-file
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2test
needs: render-compose-file
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v3
with:
compose-file-cache-key: ${{ needs.render-compose-file.outputs.compose-file-cache-key }}
compose-file-cache-path: ${{ needs.render-compose-file.outputs.compose-file-cache-path }}
server: https://app.uffizzi.com
permissions:
contents: read
pull-requests: write
id-token: write

delete-uffizzi-preview:
name: Use Remote Workflow to Delete an Existing Preview
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v3
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}

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.
compose-file-cache-key: ${{ needs.cache-compose-file.outputs.compose-file-cache-key }}
compose-file-cache-path: docker-compose.rendered.yml
server: https://app.uffizzi.com
pr-number: ${{ needs.cache-compose-file.outputs.pr-number }}

permissions:
contents: read
pull-requests: write
id-token: write
id-token: write
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Preview Environments are configured with a [Docker Compose template](docker-comp

Running this workflow will create a [Uffizzi Cloud](https://uffizzi.com) account and project from your GitHub user and repo information, respectively. If you sign in to the [Uffizzi Dashboard](https://app.uffizzi.com/sign_in) you can view logs, password protect your Preview Environments, manage projects and team members, set role-based access controls, and configure single-sign on (SSO).

Open-source projects preview for free on Uffizzi Cloud. All other accounts receive 10,000 preview minutes per month for free. If you exceed this amount, your Preview Environments will be paused unless you add a credit card. See [our pricing](https://uffizzi.com/pricing) for details or to request free access as an open-source maintainer. Alternatively, if you don't want to use Uffizzi Cloud, you can [install open-source Uffizzi](https://github.com/UffizziCloud/uffizzi_app/blob/develop/INSTALL.md) on your own Kubernetes cluster.
Open-source projects preview for free on Uffizzi Cloud. All other accounts can subscribe to our Starter or Pro plans. See [our pricing](https://uffizzi.com/pricing) for details. Or if you're an open-source maintainer, you can request free access as by sending an email to [email protected]. Alternatively, if you don't want to use Uffizzi Cloud, you can [install open-source Uffizzi](https://github.com/UffizziCloud/uffizzi_app/blob/develop/INSTALL.md) on your own Kubernetes cluster.


## Acceptable Use

Expand Down
2 changes: 1 addition & 1 deletion result/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:10-slim
FROM node:18-slim

# add curl for healthcheck
# add wait-for-it to delay start
Expand Down
Loading