69 lines
2.0 KiB
YAML
69 lines
2.0 KiB
YAML
name: Build And Release Templates
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Podman
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y podman
|
|
|
|
- name: Build production image
|
|
run: podman build --target runtime -t ci-cd-email-templates:${{ github.sha }} .
|
|
|
|
- name: Render HTML templates
|
|
run: |
|
|
mkdir -p build/html
|
|
podman run --rm \
|
|
-e OUTPUT_DIR=/workspace/build/html \
|
|
-v "${GITHUB_WORKSPACE}/build/html:/workspace/build/html" \
|
|
ci-cd-email-templates:${{ github.sha }}
|
|
|
|
- name: Upload rendered templates artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rendered-email-templates
|
|
path: build/html/*.html
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Download rendered templates
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rendered-email-templates
|
|
path: release/html
|
|
|
|
- name: Upload templates to Cloudflare R2
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: auto
|
|
AWS_EC2_METADATA_DISABLED: true
|
|
CF_R2_ACCOUNT_ID: ${{ secrets.CF_R2_ACCOUNT_ID }}
|
|
CF_R2_BUCKET: ${{ secrets.CF_R2_BUCKET }}
|
|
CF_R2_PREFIX: ${{ vars.CF_R2_PREFIX }}
|
|
run: |
|
|
ENDPOINT="https://${CF_R2_ACCOUNT_ID}.r2.cloudflarestorage.com"
|
|
TARGET="s3://${CF_R2_BUCKET}"
|
|
if [ -n "${CF_R2_PREFIX}" ]; then
|
|
TARGET="${TARGET}/${CF_R2_PREFIX}"
|
|
fi
|
|
aws s3 sync release/html "${TARGET}" --endpoint-url "${ENDPOINT}" --delete
|