Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
20de0927da
|
|||
4f8fe9e768
|
|||
15669c3861
|
@@ -12,50 +12,59 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
docker:
|
||||||
|
image: docker:dind
|
||||||
|
env:
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
|
container:
|
||||||
|
image: docker:24-git
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
env:
|
env:
|
||||||
REGISTRY: hub.realmanual.ru
|
REGISTRY: hub.realmanual.ru
|
||||||
IMAGE_NAME: pub/sqlite-backup/backup
|
IMAGE_NAME: pub/sqlite-backup/backup
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout (git)
|
||||||
uses: actions/checkout@v4
|
shell: sh
|
||||||
with:
|
env:
|
||||||
fetch-depth: 0
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|
||||||
- name: Ensure tag commit is reachable from main
|
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -eu
|
||||||
git fetch --no-tags --depth=0 origin main
|
: "${GITHUB_SERVER_URL:?}"
|
||||||
if git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
|
: "${GITHUB_REPOSITORY:?}"
|
||||||
echo "Commit is on main history. Proceeding."
|
: "${GITHUB_SHA:?}"
|
||||||
else
|
git init .
|
||||||
echo "Tag commit is not from main. Skipping build." >&2
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||||
exit 0
|
git -c http.extraHeader="Authorization: Bearer ${TOKEN}" fetch --no-tags --depth=1 origin "${GITHUB_SHA}"
|
||||||
fi
|
git checkout --detach "${GITHUB_SHA}"
|
||||||
|
|
||||||
- name: Extract tag
|
- name: Extract tag
|
||||||
id: vars
|
id: vars
|
||||||
shell: bash
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
TAG_REF="${GITHUB_REF#refs/tags/}"
|
TAG_REF="${GITHUB_REF#refs/tags/}"
|
||||||
echo "tag=$TAG_REF" >> "$GITHUB_OUTPUT"
|
echo "tag=$TAG_REF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Docker login
|
||||||
uses: docker/setup-buildx-action@v3
|
shell: sh
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login "${{ env.REGISTRY }}" --username "${{ github.actor }}" --password-stdin
|
||||||
|
|
||||||
- name: Log in to registry
|
- name: Build image
|
||||||
uses: docker/login-action@v3
|
shell: sh
|
||||||
with:
|
run: |
|
||||||
registry: ${{ env.REGISTRY }}
|
set -eu
|
||||||
username: ${{ github.actor }}
|
docker build \
|
||||||
password: ${{ secrets.GITEA_TOKEN }}
|
-t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.tag }}" \
|
||||||
|
-t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" \
|
||||||
|
.
|
||||||
|
|
||||||
- name: Build and push
|
- name: Push images
|
||||||
uses: docker/build-push-action@v6
|
shell: sh
|
||||||
with:
|
run: |
|
||||||
context: .
|
set -eu
|
||||||
push: true
|
docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.tag }}"
|
||||||
platforms: linux/amd64
|
docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.tag }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
|
Reference in New Issue
Block a user