forked from odoo/odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 2 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build Docker Image
on:
push:
branches:
- 'jobrad-**'
tags:
- 'jobrad-**'
jobs:
build-docker:
runs-on: [self-hosted, short]
permissions:
contents: read
packages: write
env:
GHCR_IMAGE_NAME: ghcr.io/jobrad-gmbh/odoo
ARTIFACTORY_IMAGE_NAME: artifactory.service.jobrad.org/jra_docker_registry/odoo
steps:
- uses: actions/checkout@v3
- name: Create variables
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/heads\///' | sed 's/refs\/tags\///' | sed 's/\//_/g')" >> $GITHUB_ENV
echo "SHORT_REV=$(echo ${{ github.sha }})" >> $GITHUB_ENV
- name: Login to ghcr registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to artifactory registry
uses: docker/login-action@v2
with:
registry: artifactory.service.jobrad.org
username: github_runner
password: ${{ secrets.ARTIFACTORY_TOKEN }}
- name: Build the Docker image
shell: bash
run: |
if docker pull "${GHCR_IMAGE_NAME}:${SHORT_REV}"; then
docker image tag "${GHCR_IMAGE_NAME}:${SHORT_REV}" "${GHCR_IMAGE_NAME}:${BRANCH_NAME}"
else
echo "Docker image tag ${SHORT_REV} doesn't exist yet"
docker build . -f docker/Dockerfile -t "${GHCR_IMAGE_NAME}:${BRANCH_NAME}" -t "${GHCR_IMAGE_NAME}:${SHORT_REV}" --pull
fi
- name: Push Image to ghcr
run: |
docker push "${GHCR_IMAGE_NAME}:${SHORT_REV}"
docker push "${GHCR_IMAGE_NAME}:${BRANCH_NAME}"
- name: Push Image to artifactory
run: |
docker tag "${GHCR_IMAGE_NAME}:${SHORT_REV}" "${ARTIFACTORY_IMAGE_NAME}:${SHORT_REV}"
docker tag "${GHCR_IMAGE_NAME}:${BRANCH_NAME}" "${ARTIFACTORY_IMAGE_NAME}:${BRANCH_NAME}"
docker push "${ARTIFACTORY_IMAGE_NAME}:${SHORT_REV}"
docker push "${ARTIFACTORY_IMAGE_NAME}:${BRANCH_NAME}"