* Simplify Uffizzi setup & use cached assets * Remove cache assets usage * Don't feature too many articles in seed * Update db/seeds.rb
84 lines
3 KiB
YAML
84 lines
3 KiB
YAML
name: Build PR Image
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, closed]
|
|
|
|
jobs:
|
|
build-application:
|
|
name: Build and Push `Forem`
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
|
|
outputs:
|
|
compose-file-cache-key: ${{ steps.hash.outputs.hash }}
|
|
compose-file-cache-path: docker-compose.rendered.yml
|
|
steps:
|
|
- name: Checkout git repo
|
|
uses: actions/checkout@v3
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Generate UUID image name
|
|
id: uuid
|
|
run: echo "UUID_TAG_APP=$(uuidgen)" >> $GITHUB_ENV
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: registry.uffizzi.com/${{ env.UUID_TAG_APP }}
|
|
tags: type=raw,value=60d
|
|
- uses: actions/checkout@master
|
|
- name: Create the .env file
|
|
run: |
|
|
cp .env.test .env
|
|
- name: Build and Push Image to registry.uffizzi.com ephemeral registry
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
context: .
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
file: ./uffizzi/Dockerfile
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
- uses: actions/checkout@v3
|
|
- name: Render Compose File
|
|
run: |
|
|
APP_IMAGE=$(echo ${{ steps.meta.outputs.tags }})
|
|
export APP_IMAGE
|
|
export UFFIZZI_URL=\$UFFIZZI_URL
|
|
envsubst '$APP_IMAGE' < ./uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml
|
|
cat docker-compose.rendered.yml
|
|
- name: Hash Rendered Compose File
|
|
id: hash
|
|
run: echo "::set-output name=hash::$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')"
|
|
- name: Cache Rendered Compose File
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: docker-compose.rendered.yml
|
|
key: ${{ steps.hash.outputs.hash }}
|
|
|
|
deploy-uffizzi-preview:
|
|
name: Deploy preview
|
|
needs: build-application
|
|
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2
|
|
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
|
|
with:
|
|
compose-file-cache-key: ${{ needs.build-application.outputs.compose-file-cache-key }}
|
|
compose-file-cache-path: ${{ needs.build-application.outputs.compose-file-cache-path }}
|
|
server: https://app.uffizzi.com/
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
id-token: write
|
|
|
|
delete-uffizzi-preview:
|
|
name: Delete preview
|
|
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2
|
|
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
|
|
with:
|
|
compose-file-cache-key: ''
|
|
compose-file-cache-path: docker-compose.rendered.yml
|
|
server: https://app.uffizzi.com/
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
id-token: write
|