Skip to content

Merge pull request #292 from retrom-project/codex/psp-game-save #179

Merge pull request #292 from retrom-project/codex/psp-game-save

Merge pull request #292 from retrom-project/codex/psp-game-save #179

Workflow file for this run

name: docker-image
on:
push:
tags: ["*"]
permissions:
contents: read
concurrency:
group: docker-image-${{ github.ref }}
cancel-in-progress: false
env:
BACKEND_IMAGE: xxxsen/retrom
WEB_IMAGE: xxxsen/retrom-web
jobs:
build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Check out the repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate the image tag
id: release
env:
IMAGE_TAG: ${{ github.ref_name }}
run: |
if [[ ! "$IMAGE_TAG" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then
echo "::error::Git tag '$IMAGE_TAG' cannot be used as a Docker image tag."
exit 1
fi
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
if [[ "$IMAGE_TAG" == *-* ]]; then
echo "publish_latest=false" >> "$GITHUB_OUTPUT"
else
echo "publish_latest=true" >> "$GITHUB_OUTPUT"
fi
- name: Validate Docker Hub credentials
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
if [[ -z "$DOCKER_USER" || -z "$DOCKER_PASSWORD" ]]; then
echo "::error::DOCKER_USER and DOCKER_PASSWORD must be configured for Docker Hub."
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
package-manager-cache: false
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Prepare the release migration manifest
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
run: make migration-manifest TAG="$IMAGE_TAG"
- name: Require stable image sources to be on master
if: steps.release.outputs.publish_latest == 'true'
run: |
git fetch --no-tags origin '+refs/heads/master:refs/remotes/origin/master'
git merge-base --is-ancestor "$GITHUB_SHA" origin/master
- name: Prepare pinned password blocklist
run: python3 scripts/dependencies.py prepare-auth --versions 4.2.3,4.3.0-pre
- name: Restore verified Provider chunks
uses: actions/cache/restore@v5
with:
path: .cache/runtime-providers
key: retrom-provider-chunks-${{ runner.os }}-${{ hashFiles('data/runtime-inputs.json') }}
restore-keys: retrom-provider-chunks-${{ runner.os }}-
- name: Materialize repository-pinned runtime inputs
env:
RETROM_RUNTIME_INPUT_BASE_URL: ${{ vars.RETROM_RUNTIME_INPUT_BASE_URL }}
run: python3 scripts/prepare_image_inputs.py
- name: Build and verify both images
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
run: make build-images BACKEND_IMAGE="$BACKEND_IMAGE" WEB_IMAGE="$WEB_IMAGE" IMAGE_TAG="$IMAGE_TAG"
- name: Verify both images and their deployment connection
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
run: bash scripts/verify-backend-image.sh "$BACKEND_IMAGE:$IMAGE_TAG" "$WEB_IMAGE:$IMAGE_TAG"
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push versioned images
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
run: |
docker push "$BACKEND_IMAGE:$IMAGE_TAG"
docker push "$WEB_IMAGE:$IMAGE_TAG"
- name: Push latest images for a stable tag
if: steps.release.outputs.publish_latest == 'true'
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
run: |
docker tag "$BACKEND_IMAGE:$IMAGE_TAG" "$BACKEND_IMAGE:latest"
docker tag "$WEB_IMAGE:$IMAGE_TAG" "$WEB_IMAGE:latest"
docker push "$BACKEND_IMAGE:latest"
docker push "$WEB_IMAGE:latest"
- name: Record the released migration manifest
uses: actions/upload-artifact@v4
with:
name: released-migrations-${{ steps.release.outputs.image_tag }}
path: .artifacts/release/migrations.json
include-hidden-files: true
if-no-files-found: error