feat: auto-build image on new upstream tag
Signed-off-by: Victoria Nadasdi <victoria@efertone.me>
This commit is contained in:
parent
d6ff40acea
commit
56614e8519
2 changed files with 36 additions and 3 deletions
37
.github/workflows/build-and-publish.yaml
vendored
37
.github/workflows/build-and-publish.yaml
vendored
|
@ -7,10 +7,14 @@ on:
|
||||||
description: Target Phanpy version
|
description: Target Phanpy version
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
default: latest
|
||||||
|
schedule:
|
||||||
|
- cron: "0 */6 * * *"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
UPSTREAM: cheeaun/phanpy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_push_to_registry:
|
build_and_push_to_registry:
|
||||||
|
@ -20,28 +24,57 @@ jobs:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
echo "### Status" >> ${GITHUB_STEP_SUMMARY}
|
||||||
|
|
||||||
|
tag="${{ inputs.logLevel || 'latest' }}"
|
||||||
|
|
||||||
|
if [[ "${tag}" == "latest" ]]; then
|
||||||
|
tag=$(curl -s https://api.github.com/repos/${UPSTREAM}/releases/latest \
|
||||||
|
| jq --raw-output '.tag_name')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "value=${tag}" >> ${GITHUB_OUTPUT}
|
||||||
|
echo " - Tag: ${tag}" >> ${GITHUB_STEP_SUMMARY}
|
||||||
|
- uses: warjiang/setup-skopeo@main
|
||||||
|
- name: Check if tag needs_update
|
||||||
|
id: tag_check
|
||||||
|
run: |
|
||||||
|
if skopeo inspect docker://${REGISTRY}/${IMAGE_NAME}:${{ steps.version.outputs.value }}; then
|
||||||
|
echo ":green_square: We are up to date!" >> ${GITHUB_STEP_SUMMARY}
|
||||||
|
echo "needs_update=false"
|
||||||
|
else
|
||||||
|
echo ":red_square: **Update required!**" >> ${GITHUB_STEP_SUMMARY}
|
||||||
|
echo "needs_update=true"
|
||||||
|
fi
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Extract metadata for Docker
|
- name: Extract metadata for Docker
|
||||||
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ inputs.phanpy_version }}
|
${{ steps.version.outputs.value }}
|
||||||
latest
|
latest
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ inputs.phanpy_version }}
|
VERSION=${{ steps.version.outputs.value }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
|
@ -13,7 +13,7 @@ docker run ghcr.io/yitsushi/phanpy-docker:latest
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
services:
|
services:
|
||||||
phanpy:
|
phanpy:
|
||||||
image: ghcr.io/cheeaun/phanpy:latest
|
image: ghcr.io/yitsushi/phanpy-docker:latest
|
||||||
container_name: phanpy
|
container_name: phanpy
|
||||||
ports:
|
ports:
|
||||||
- 8080:80
|
- 8080:80
|
||||||
|
|
Loading…
Reference in a new issue