Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 9 additions & 31 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ jobs:
needs: get-version
strategy:
matrix:
variant:
- dockerfile: Dockerfile
name: full
- dockerfile: scripting.Dockerfile
name: scripting
- dockerfile: webhooks.Dockerfile
name: webhooks
- dockerfile: minimal.Dockerfile
name: minimal
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
env:
Expand All @@ -53,32 +44,19 @@ jobs:
MAJOR=$(echo "$CLEAN_VERSION" | cut -d. -f1)
MINOR=$(echo "$CLEAN_VERSION" | cut -d. -f2)

VARIANT="${{ matrix.variant.name }}"

# Initialize empty tag list
TAGS=""

# Check if this is a prerelease
if [[ "$CLEAN_VERSION" =~ -(rc|alpha|beta) ]]; then
# Full builds get some unqualified tags
if [[ "$VARIANT" == "full" ]]; then
TAGS="ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION"
fi
# Pre-release: only full version with suffix
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION-$VARIANT"
# pre-release tags
TAGS="ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION"
else
# Full build gets special, unqualified tags
if [[ "$VARIANT" == "full" ]]; then
TAGS="ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:latest"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.$MINOR.X"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.X.X"
fi
# All variants get qualified tags
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:latest-$VARIANT"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION-$VARIANT"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.$MINOR.X-$VARIANT"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.X.X-$VARIANT"
# ordinary tags
TAGS="ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:latest"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$CLEAN_VERSION"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.$MINOR.X"
TAGS="$TAGS,ghcr.io/${GITHUB_REPOSITORY_OWNER}/basalt-server:$MAJOR.X.X"
fi

# Remove leading/trailing commas if any
Expand All @@ -104,11 +82,11 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build & push ${{ matrix.variant.name }} (${{ matrix.arch }})
- name: Build & push (${{ matrix.arch }})
uses: docker/build-push-action@v6
with:
context: .
file: ./containers/${{ matrix.variant.dockerfile }}
file: ./containers/Dockerfile
platforms: ${{ matrix.arch == 'amd64' && 'linux/amd64' || 'linux/arm64' }}
push: true
tags: ${{ steps.tags.outputs.tags }}
23 changes: 2 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ jobs:
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- dockerfile: Dockerfile
tags:
- ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}
- ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}-full
- dockerfile: scripting.Dockerfile
tags:
- ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}-scripting
- dockerfile: webhooks.Dockerfile
tags:
- ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}-webhooks
- dockerfile: minimal.Dockerfile
tags:
- ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}-minimal
steps:
- uses: actions/checkout@v4
# - name: Set up QEMU (for ARM builds)
Expand All @@ -168,16 +152,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Use QEMU to build images for both amd64 and arm64
- name: Build and push Docker image
# uses: docker/build-push-action@v6
uses: useblacksmith/build-push-action@v2
with:
context: .
file: ./containers/${{ matrix.dockerfile }}
file: ./containers/Dockerfile
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: true
# tags: ghcr.io/${{ github.repository_owner }}/basalt-server-${{ matrix.tagSuffix }}:pr-${{ github.event.pull_request.number }}
tags: |
${{ join(matrix.tags, ',') }}
tags: ghcr.io/${{ github.repository_owner }}/basalt-server:dev-pr-${{ github.event.pull_request.number }}
48 changes: 9 additions & 39 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,13 @@ jobs:
contents: read
packages: write
steps:
- name: Delete GHCR images for PR
run: |
PR_TAG_PREFIX="dev-pr-${{ github.event.pull_request.number }}"
PACKAGE_NAME="basalt-server"
REPO_OWNER="${{ github.repository_owner }}"

echo "Fetching all versions of $PACKAGE_NAME..."

# Fetch all versions from GHCR (first 100)
VERSIONS=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/orgs/$REPO_OWNER/packages/container/$PACKAGE_NAME/versions?per_page=100")
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Loop through each version
echo "$VERSIONS" | jq -c '.[]' | while read -r version; do
VERSION_ID=$(echo "$version" | jq -r '.id')
TAGS=$(echo "$version" | jq -r '.metadata.container.tags[]?')

# Delete if any tag starts with PR_TAG_PREFIX OR there are no tags
DELETE=false
if [ -z "$TAGS" ]; then
DELETE=true
else
for TAG in $TAGS; do
if [[ "$TAG" == $PR_TAG_PREFIX* ]]; then
DELETE=true
break
fi
done
fi

if [ "$DELETE" = true ]; then
echo "Deleting $PACKAGE_NAME version $VERSION_ID (tags: $TAGS)..."
curl -s -X DELETE \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/orgs/$REPO_OWNER/packages/container/$PACKAGE_NAME/versions/$VERSION_ID"
fi
done
- name: Delete PR image tag
run: |
skopeo delete docker://ghcr.io/${{ github.repository }}:dev-pr-${{ github.event.number }}
Loading
Loading