Skip to content

update: add scenari version to env variables so we do not need to wri… #19

update: add scenari version to env variables so we do not need to wri…

update: add scenari version to env variables so we do not need to wri… #19

name: "build-pubtodockerhub"
# IMPORTANT : personnalisez cette variable pour que les images
# de votre application soient pousées sur dockerhub
# dans le repository ayant ce nom
# exemple, si vous indiquez : abesesr/theses
# alors l'image sera poussée sur https://hub.docker.com/r/abesesr/documentation
env:
DOCKERHUB_IMAGE_PREFIX: abesesr/documentation
on:
push:
paths-ignore:
- '**.md'
- '.github/**'
branches:
- main
- test
- develop
pull_request:
branches:
- main
- test
- develop
workflow_dispatch:
jobs:
build-pubtodockerhub:
runs-on: ubuntu-latest
steps:
- name: "Build: checkout source code"
uses: actions/checkout@v4
with:
submodules: recursive
- name: "Build: update submodules"
run: |
git submodule sync
git submodule update --init --recursive
cd config-module
git checkout main
git pull origin main
cd ..
- name: "Build: build docker image"
run: |
docker build --build-arg DOCUMENTATION_API_PUBLISH_SCENARI_API_FOLDER=${GITHUB_REF#refs/heads/} . -t localimage:latest
- name: "Push: prepare version from git tags/branchs"
id: docker_tag_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_IMAGE_PREFIX }}
- name: "Push: login to DockerHub"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'|| github.ref == 'refs/heads/test' || startsWith(github.ref, 'refs/tags/'))
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: "Push: push docker image"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test' || startsWith(github.ref, 'refs/tags/'))
run: |
DOCKER_TAGS="${{ steps.docker_tag_meta.outputs.tags }}"
for DOCKER_TAG in $DOCKER_TAGS
do
# publication de l'image pour le front
docker build --build-arg DOCUMENTATION_API_PUBLISH_SCENARI_API_FOLDER=${GITHUB_REF#refs/heads/} . -t ${DOCKER_TAG}-documentation-api-publish
docker push ${DOCKER_TAG}-documentation-api-publish
done