mirror of
https://github.com/stxer/explorer.git
synced 2026-01-12 16:53:07 +08:00
49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
name: Create and publish Docker image
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
rev:
|
|
description: 'branch or tag or commit to build'
|
|
required: true
|
|
default: 'main'
|
|
tag-name:
|
|
description: 'image tag name'
|
|
required: true
|
|
default: 'latest'
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
TAG_NAME: ${{ github.event.inputs.tag-name }}
|
|
REV: ${{ github.event.inputs.rev }}
|
|
PRE_BUILD_SCRIPT: ${{ secrets.PRE_BUILD_SCRIPT }}
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ github.event.inputs.tag-name }} with ${{ github.event.inputs.rev }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Build and push Docker image
|
|
run: |
|
|
bash -c "$PRE_BUILD_SCRIPT"
|
|
pushd source
|
|
git rev-parse HEAD
|
|
popd
|
|
export IMAGE_TAG="$REGISTRY/$IMAGE_NAME:$TAG_NAME"
|
|
echo "Building image $IMAGE_TAG"
|
|
docker build -t $IMAGE_TAG .
|
|
docker push $IMAGE_TAG
|