Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a8356f8e1 | |||
| 3c0d37a439 | |||
| 77444bcdac | |||
| 1f6ce384f0 | |||
| de71278bf9 | |||
| aeae290ec9 | |||
| bb01522c78 | |||
| fb63b34072 |
@@ -1,73 +1,56 @@
|
|||||||
name: ci
|
name: ci/cd to build and push docker image in private registry
|
||||||
|
|
||||||
#https://docs.docker.com/build/ci/github-actions/push-multi-registries/
|
#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
|
#https://www.devsync.se/ci/cd/docker/2023/10/27/gitea-runner-build-docker-containers.html
|
||||||
|
|
||||||
|
|
||||||
# on:
|
|
||||||
# push:
|
|
||||||
# # Sequence of patterns matched against refs/heads
|
|
||||||
# branches:
|
|
||||||
# - 'main'
|
|
||||||
# # Sequence of patterns matched against refs/tags
|
|
||||||
# tags:
|
|
||||||
# - '*'
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Sequence of patterns matched against refs/tags
|
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
|
|
||||||
# push:
|
|
||||||
# branches:
|
|
||||||
# - 'main'
|
|
||||||
# tags: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
#runs-on: ubuntu-latest:docker://node:16-bullseye
|
||||||
|
#runs-on: ubuntu-latest:docker://debian:bullseye
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Print Gitea runner tag
|
- name: Print version and repository
|
||||||
run: echo ${{ gitea.run_id }}
|
run: echo "Runner working on repository ${{ gitea.repository }} and on tag ${{ gitea.ref_name }}"
|
||||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
|
||||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
|
||||||
- run: echo "🚀 I am running on tag ${{ gitea.event.release.tag_name }}!"
|
|
||||||
|
|
||||||
# INSTALL docker
|
- name: Install Docker engine
|
||||||
# - run: apt-get update
|
run: |
|
||||||
# - run: apt-get -y install curl dnsutils
|
apt-get update
|
||||||
# - run: install -m 0755 -d /etc/apt/keyrings
|
apt-get -y install curl dnsutils
|
||||||
# - run: curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
# - run: chmod a+r /etc/apt/keyrings/docker.gpg
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
# - run: echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||||
# - run: apt-get update
|
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
# - run: apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
apt-get update
|
||||||
|
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
|
||||||
|
|
||||||
# BUILD & PUSH
|
- name: Print docker images
|
||||||
- name: Checkout private git repo
|
run: docker images
|
||||||
|
|
||||||
|
- name: Git clone private repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# tape git@gitea.jingoh.fr port 22 et pas port 443 cet ane (should be ssh://gitea.jingoh.fr:443/$repository au lieu de ssh://gitea.jingoh.fr:$repository)
|
repository: ${{ gitea.repository }}
|
||||||
repository: staffadmin/gitea-runner
|
# persist-credentials: false
|
||||||
persist-credentials: false
|
# ssh-strict: false
|
||||||
ssh-strict: false
|
|
||||||
token: ${{ secrets.ACCESS_TOKEN_GIT }}
|
token: ${{ secrets.ACCESS_TOKEN_GIT }}
|
||||||
ssh-known-hosts: ${{ secrets.SSH_KNOWN_GITEA }}
|
# ssh-known-hosts: ${{ secrets.SSH_KNOWN_GITEA }}
|
||||||
- name: Print Gitea runner tag
|
|
||||||
run: echo "Tag name from GITHUB_REF_NAME $GITHUB_REF_NAME"
|
- name: Login to docker private registry
|
||||||
# - name: Login to Docker private registry
|
uses: docker/login-action@v3
|
||||||
# uses: docker/login-action@v3
|
with:
|
||||||
# with:
|
registry: ${{ vars.REGISTRY_DOCKER }}
|
||||||
# registry: ${{ vars.REGISTRY_DOCKER }}
|
username: ${{ secrets.REGISTRY_DOCKER_USER }}
|
||||||
# username: ${{ secrets.REGISTRY_DOCKER_USER }}
|
password: ${{ secrets.REGISTRY_DOCKER_PASS }}
|
||||||
# password: ${{ secrets.REGISTRY_DOCKER_PASS }}
|
|
||||||
# - name: Build and push
|
- name: Build and push image in registry
|
||||||
# uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
# with:
|
with:
|
||||||
# context: .
|
context: .
|
||||||
# push: true
|
push: true
|
||||||
# tags: ${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:latest,${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:1.0.2
|
tags: ${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:latest,${{ vars.REGISTRY_DOCKER }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ gitea.ref_name }}
|
||||||
# # secrets: |
|
|
||||||
# # GIT_AUTH_TOKEN=${{ secrets.ACCESS_TOKEN_GIT }}
|
|
||||||
Reference in New Issue
Block a user