updated diff location #65
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |