This commit is contained in:
@@ -6,8 +6,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: git.alexmickelson.guru
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -16,8 +15,6 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
outputs:
|
|
||||||
image-digest: ${{ steps.build.outputs.digest }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -25,7 +22,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
- name: Log in to Gitea Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
@@ -35,12 +32,12 @@ jobs:
|
|||||||
- name: Build and push image
|
- name: Build and push image
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
IMAGE="alexmickelson/cobblemon:${{ github.run_number }}"
|
IMAGE="${{ env.REGISTRY }}/alexmickelson/cobblemon:${{ github.run_number }}"
|
||||||
docker build --push -t "${IMAGE}" .
|
docker build --push -t "${IMAGE}" .
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
IMAGE="alexmickelson/cobblemon:${{ github.run_number }}"
|
IMAGE="${{ env.REGISTRY }}/alexmickelson/cobblemon:${{ github.run_number }}"
|
||||||
|
|
||||||
kubectl get secret cobblemon-ui-secret --namespace=cobblemon 2>/dev/null || \
|
kubectl get secret cobblemon-ui-secret --namespace=cobblemon 2>/dev/null || \
|
||||||
kubectl create secret generic cobblemon-ui-secret \
|
kubectl create secret generic cobblemon-ui-secret \
|
||||||
@@ -54,3 +51,14 @@ jobs:
|
|||||||
kubectl rollout status deployment/cobblemon-ui \
|
kubectl rollout status deployment/cobblemon-ui \
|
||||||
--namespace=cobblemon \
|
--namespace=cobblemon \
|
||||||
--timeout=5m
|
--timeout=5m
|
||||||
|
|
||||||
|
- name: Cleanup old images
|
||||||
|
run: |
|
||||||
|
# Delete all container image versions except the most recent one
|
||||||
|
VERSIONS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"${{ env.REGISTRY }}/api/v1/packages/alexmickelson?type=container&q=cobblemon&limit=50" \
|
||||||
|
| jq -r 'sort_by(.created) | reverse | .[1:] | .[].id')
|
||||||
|
for id in $VERSIONS; do
|
||||||
|
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"${{ env.REGISTRY }}/api/v1/packages/alexmickelson/container/cobblemon/${id}"
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user