1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-28 09:08:41 +02:00

Uffizzi PR: Update Uffizzi Workflows (#2502)

This commit is contained in:
Shruti Chaturvedi 2023-03-18 06:03:07 +05:30 committed by GitHub
parent 5c8bc790ff
commit 81ea3107ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 16 deletions

View File

@ -20,12 +20,12 @@ jobs:
run: echo "UUID_APP_TAG=$(uuidgen)" >> $GITHUB_ENV run: echo "UUID_APP_TAG=$(uuidgen)" >> $GITHUB_ENV
- name: Docker metadata - name: Docker metadata
id: meta id: meta
uses: docker/metadata-action@v3 uses: docker/metadata-action@v4
with: with:
images: registry.uffizzi.com/${{ env.UUID_APP_TAG }} images: registry.uffizzi.com/${{ env.UUID_APP_TAG }}
tags: type=raw,value=60d tags: type=raw,value=60d
- name: Build and Push Image to registry.uffizzi.com ephemeral registry - name: Build and Push Image to registry.uffizzi.com ephemeral registry
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
push: true push: true
context: ./ context: ./
@ -60,17 +60,11 @@ jobs:
name: preview-spec name: preview-spec
path: docker-compose.rendered.yml path: docker-compose.rendered.yml
retention-days: 2 retention-days: 2
- name: Serialize PR Event to File
run: |
cat << EOF > event.json
${{ toJSON(github.event) }}
EOF
- name: Upload PR Event as Artifact - name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: preview-spec name: preview-spec
path: event.json path: ${{ github.event_path }}
retention-days: 2 retention-days: 2
delete-preview: delete-preview:
@ -79,11 +73,9 @@ jobs:
if: ${{ github.event.action == 'closed' }} if: ${{ github.event.action == 'closed' }}
steps: steps:
# If this PR is closing, we will not render a compose file nor pass it to the next workflow. # 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 - name: Upload PR Event as Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: preview-spec name: preview-spec
path: event.json path: ${{ github.event_path }}
retention-days: 2 retention-days: 2

View File

@ -7,11 +7,11 @@ on:
types: types:
- completed - completed
jobs: jobs:
cache-compose-file: cache-compose-file:
name: Cache Compose File name: Cache Compose File
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs: outputs:
compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }} compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }}
pr-number: ${{ env.PR_NUMBER }} pr-number: ${{ env.PR_NUMBER }}
@ -29,6 +29,9 @@ jobs:
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "preview-spec" return artifact.name == "preview-spec"
})[0]; })[0];
if (matchArtifact === undefined) {
throw TypeError('Build Artifact not found!');
}
let download = await github.rest.actions.downloadArtifact({ let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@ -39,16 +42,18 @@ jobs:
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data)); fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));
- name: 'Unzip artifact' - name: 'Unzip artifact'
run: unzip preview-spec.zip run: unzip preview-spec.zip
- name: Read Event into ENV - name: Read Event into ENV
run: | run: |
echo 'EVENT_JSON<<EOF' >> $GITHUB_ENV echo 'EVENT_JSON<<EOF' >> $GITHUB_ENV
cat event.json >> $GITHUB_ENV cat event.json >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV echo -e '\nEOF' >> $GITHUB_ENV
- name: Hash Rendered Compose File - name: Hash Rendered Compose File
id: hash id: hash
# If the previous workflow was triggered by a PR close event, we will not have a compose file artifact. # 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' }} if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
run: echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_ENV run: echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Cache Rendered Compose File - name: Cache Rendered Compose File
if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }} if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
uses: actions/cache@v3 uses: actions/cache@v3
@ -70,7 +75,8 @@ jobs:
name: Use Remote Workflow to Preview on Uffizzi name: Use Remote Workflow to Preview on Uffizzi
needs: needs:
- cache-compose-file - 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: with:
# If this workflow was triggered by a PR close event, cache-key will be an empty string # 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. # and this reusable workflow will delete the preview deployment.
@ -81,4 +87,4 @@ jobs:
permissions: permissions:
contents: read contents: read
pull-requests: write pull-requests: write
id-token: write id-token: write