52 lines
1.9 KiB
YAML
52 lines
1.9 KiB
YAML
name: ci/cd to build and push docker image in private registry
|
|
|
|
#https://docs.docker.com/build/ci/github-actions/push-multi-registries/
|
|
#https://www.devsync.se/ci/cd/docker/2023/10/27/gitea-runner-build-docker-containers.html
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
# Be carefull, conflict with package-deb *.*.*, don't use more than on dot *.* (ex: 2.5-runner)
|
|
- '*runner*'
|
|
|
|
jobs:
|
|
build-and-push-debian-runner:
|
|
# see on runner /data/.runner to add label (test => test:docker://debian:bullseye)
|
|
# runs-on: test
|
|
# container: debian:bullseye
|
|
# runs-on: ubuntu-latest
|
|
# container: node:16-bullseye
|
|
runs-on: debian-runner
|
|
container:
|
|
image: ${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
|
|
credentials:
|
|
username: ${{ secrets.REGISTRY_DOCKER_USER }}
|
|
password: ${{ secrets.REGISTRY_DOCKER_PASS }}
|
|
|
|
|
|
steps:
|
|
- name: Show Information
|
|
run: echo "Runner ${{ runner.os }} working on repository ${{ gitea.repository }} and on tag ${{ gitea.ref_name }}"
|
|
|
|
- name: Git clone private repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ gitea.repository }}
|
|
token: ${{ secrets.REPO_PULL_GITEA }}
|
|
|
|
- name: Login to docker private registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.REGISTRY_DOCKER }}
|
|
username: ${{ secrets.REGISTRY_DOCKER_USER }}
|
|
password: ${{ secrets.REGISTRY_DOCKER_PASS }}
|
|
|
|
- name: Build and push image in registry
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:latest,${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ gitea.ref_name }}
|
|
|
|
- name: Output
|
|
run: echo "Push on ${{ vars.REGISTRY_DOCKER }} image ${{ vars.DOCKER_IMAGE_NAME }} tag ${{ gitea.ref_name }}" |