2024-04-16 10:59:57 -05:00
|
|
|
name: Publish Docker image
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
phanpy_version:
|
|
|
|
description: Target Phanpy version
|
|
|
|
required: true
|
|
|
|
type: string
|
2024-04-20 14:48:36 -05:00
|
|
|
default: latest
|
|
|
|
schedule:
|
|
|
|
- cron: "0 */6 * * *"
|
2024-04-16 10:59:57 -05:00
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
2024-04-20 14:48:36 -05:00
|
|
|
UPSTREAM: cheeaun/phanpy
|
2024-04-16 10:59:57 -05:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_and_push_to_registry:
|
|
|
|
name: "Build and Push to Registry: phanpy ${{ inputs.phanpy_version }}"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
2024-04-20 14:48:36 -05:00
|
|
|
- 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}
|
2024-05-06 13:10:58 -05:00
|
|
|
echo "needs_update=false" >> ${GITHUB_OUTPUT}
|
2024-04-20 14:48:36 -05:00
|
|
|
else
|
|
|
|
echo ":red_square: **Update required!**" >> ${GITHUB_STEP_SUMMARY}
|
2024-05-06 13:10:58 -05:00
|
|
|
echo "needs_update=true" >> ${GITHUB_OUTPUT}
|
2024-04-20 14:48:36 -05:00
|
|
|
fi
|
2024-04-16 10:59:57 -05:00
|
|
|
- name: Checkout repository
|
2024-04-20 14:48:36 -05:00
|
|
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
2024-04-16 10:59:57 -05:00
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to the Container registry
|
2024-04-20 14:48:36 -05:00
|
|
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
2024-04-16 10:59:57 -05:00
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata for Docker
|
2024-04-20 14:48:36 -05:00
|
|
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
2024-04-16 10:59:57 -05:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
2024-04-16 11:15:54 -05:00
|
|
|
tags: |
|
2024-04-20 14:48:36 -05:00
|
|
|
${{ steps.version.outputs.value }}
|
2024-04-16 11:24:39 -05:00
|
|
|
latest
|
2024-04-16 10:59:57 -05:00
|
|
|
- name: Build and push Docker image
|
2024-04-20 14:48:36 -05:00
|
|
|
if: ${{ steps.tag_check.outputs.needs_update == 'true' }}
|
2024-04-16 10:59:57 -05:00
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
build-args: |
|
2024-04-20 14:48:36 -05:00
|
|
|
VERSION=${{ steps.version.outputs.value }}
|
2024-04-16 10:59:57 -05:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|