42 lines
1.3 KiB
YAML
42 lines
1.3 KiB
YAML
name: Cleanup Preview
|
|
description: Stop container and remove Pangolin resource for a deleted branch
|
|
|
|
inputs:
|
|
app-name:
|
|
required: true
|
|
description: Application name (used for image/container naming)
|
|
branch:
|
|
required: true
|
|
description: Branch name being cleaned up
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Derive cleanup parameters
|
|
id: derive
|
|
shell: bash
|
|
env:
|
|
BRANCH: ${{ inputs.branch }}
|
|
run: |
|
|
BRANCH="${BRANCH#refs/heads/}"
|
|
SLUG=$(echo "$BRANCH" | tr '/_' '--' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | cut -c1-40)
|
|
REPO_SLUG="${GITHUB_REPOSITORY//\//-}"
|
|
{
|
|
echo "slug=$SLUG"
|
|
echo "resource-name=${REPO_SLUG}-${SLUG}"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Remove Pangolin resource
|
|
shell: bash
|
|
run: |
|
|
bash ${{ github.action_path }}/pangolin-delete.sh \
|
|
--resource-name "${{ steps.derive.outputs.resource-name }}"
|
|
|
|
- name: Stop preview container
|
|
shell: bash
|
|
run: |
|
|
CONTAINER="${{ inputs.app-name }}-${{ steps.derive.outputs.slug }}"
|
|
docker stop "$CONTAINER" 2>/dev/null || true
|
|
docker rm "$CONTAINER" 2>/dev/null || true
|
|
docker rmi "${{ inputs.app-name }}:${{ steps.derive.outputs.slug }}" 2>/dev/null || true
|