Skip to content

Merge pull request #68 from SCiO-systems/odysseas-rocker #1

Merge pull request #68 from SCiO-systems/odysseas-rocker

Merge pull request #68 from SCiO-systems/odysseas-rocker #1

name: Build and Push Docker Images (rocker-eiaspatial)
on:
push:
branches:
- develop
- main
paths:
- ".github/workflows/pipeline-rocker-eiaspatial.yml"
- "rocker-eiaspatial/**"
permissions:
contents: read
jobs:
build_and_push_dev:
runs-on: "self-hosted"
if: startsWith(github.ref, 'refs/heads/develop')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get short SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
with:
length: 7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker Image (dev)
uses: docker/build-push-action@v4
with:
context: ./rocker-eiaspatial
file: ./rocker-eiaspatial/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}-${{ steps.short-sha.outputs.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
build_and_push_prod:
runs-on: "self-hosted"
if: startsWith(github.ref, 'refs/heads/main')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Pull "dev" Docker image
run: docker pull ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}
- name: Tag producion Docker image
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }} ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}
- name: Push Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}
- name: Tag producion Docker image (non specified version)
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }} ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial
- name: Push Docker image (non specified version)
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial