46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
name: Build a docker image.
|
|
|
|
on:
|
|
push:
|
|
|
|
jobs:
|
|
build-docker-image:
|
|
runs-on: nixos
|
|
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build image
|
|
run: |
|
|
nix build .#docker
|
|
|
|
- name: Push image
|
|
env:
|
|
REGISTRY: "${{ gitea.server_url }}"
|
|
REPOSITORY: "${{ gitea.repository }}"
|
|
USERNAME: "${{ gitea.actor }}"
|
|
PASSWORD: "${{ secrets.GITEA_TOKEN }}"
|
|
TAG: "${{ gitea.sha }}"
|
|
run: |
|
|
REGISTRY="${REGISTRY#https://}"
|
|
REGISTRY="${REGISTRY#http://}"
|
|
REGISTRY="${REGISTRY%/}"
|
|
|
|
IMAGE="${REGISTRY}/${REPOSITORY}:${TAG}"
|
|
|
|
echo "Pushing ${IMAGE}"
|
|
|
|
skopeo copy \
|
|
--dest-creds "${USERNAME}:${PASSWORD}" \
|
|
"docker-archive:result" \
|
|
"docker://${IMAGE}"
|
|
|
|
# Also update latest
|
|
if [ "${GITEA_REF_TYPE}" = "branch" ] && [ "${GITEA_REF_NAME}" = "main" ]; then
|
|
skopeo copy \
|
|
--dest-creds "${USERNAME}:${PASSWORD}" \
|
|
"docker-archive:result" \
|
|
"docker://${REGISTRY}/${REPOSITORY}:latest"
|
|
fi
|