-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (43 loc) · 1.72 KB
/
build-test-pubtodockerhub.yml
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
name: "build-test-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/theses
env:
DOCKERHUB_IMAGE_PREFIX: abesesr/theses
on:
push:
paths-ignore:
- '**.md'
- '.github/**'
pull_request:
workflow_dispatch:
jobs:
build-test-pubtodockerhub:
runs-on: ubuntu-latest
steps:
- name: "Build: checkout source code"
uses: actions/checkout@v2
- name: "Build: build docker image"
run: |
docker build . -t localimage:latest
- name: "Push: prepare version from git tags/branchs"
id: docker_tag_meta
uses: docker/metadata-action@v3
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' || 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' || 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 . --target front-image -t ${DOCKER_TAG}-front
docker push ${DOCKER_TAG}-front
done