|
1 | 1 | name: Docker |
2 | 2 |
|
3 | 3 | on: |
| 4 | + workflow_dispatch: |
4 | 5 | push: |
5 | 6 | branches: |
6 | 7 | - master |
7 | | - tags: |
8 | | - - 'v*.*.*' |
9 | | - |
10 | | -jobs: |
11 | | - build-and-tag-on-merge: |
12 | | - if: github.ref == 'refs/heads/master' |
13 | | - environment : deployment |
14 | | - runs-on: ubuntu-latest |
15 | | - env: |
16 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
17 | | - steps: |
18 | | - - name: Check Out Repo |
19 | | - uses: actions/checkout@v4 |
20 | | - |
21 | | - - name: Set up Docker Buildx |
22 | | - id: buildx |
23 | | - uses: docker/setup-buildx-action@v3 |
24 | | - |
25 | | - - name: Login to Docker Hub |
26 | | - uses: docker/login-action@v3 |
27 | | - with: |
28 | | - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
29 | | - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
30 | | - |
31 | | - - id: release |
32 | | - uses: rymndhng/release-on-push-action@master |
33 | | - with: |
34 | | - bump_version_scheme: patch |
35 | | - tag_prefix: v |
36 | | - |
37 | | - - name: Cache Docker layers |
38 | | - uses: actions/cache@v3 |
39 | | - with: |
40 | | - path: /tmp/.buildx-cache |
41 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
42 | | - restore-keys: ${{ runner.os }}-buildx |
43 | | - |
44 | | - - name: Build and push |
45 | | - id: docker_build |
46 | | - uses: docker/build-push-action@v5 |
47 | | - with: |
48 | | - context: . |
49 | | - file: ./Dockerfile.prod |
50 | | - push: true |
51 | | - tags: | |
52 | | - ${{ secrets.DOCKER_HUB_REPOSITORY }}:latest |
53 | | - ${{ secrets.DOCKER_HUB_REPOSITORY }}:${{ steps.release.outputs.version }} |
54 | | - cache-from: type=local,src=/tmp/.buildx-cache |
55 | | - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new |
56 | | - |
57 | | - - name: Refresh Cache |
58 | | - run: | |
59 | | - rm -rf /tmp/.buildx-cache |
60 | | - mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
61 | | - |
62 | | - - name: Image digest |
63 | | - run: echo ${{ steps.docker_build.outputs.digest }} |
64 | | - |
65 | | - build-on-release: |
66 | | - if: startsWith(github.ref, 'refs/tags/') |
67 | | - environment : deployment |
68 | | - runs-on: ubuntu-latest |
69 | | - steps: |
70 | | - - name: Check Out Repo |
71 | | - uses: actions/checkout@v4 |
72 | | - |
73 | | - - name: Set up Docker Buildx |
74 | | - id: buildx |
75 | | - uses: docker/setup-buildx-action@v3 |
76 | | - |
77 | | - - name: Login to Docker Hub |
78 | | - uses: docker/login-action@v3 |
79 | | - with: |
80 | | - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
81 | | - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
82 | | - |
83 | | - - name: Get Tag Version |
84 | | - id: tag |
85 | | - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
86 | | - |
87 | | - - name: Cache Docker layers |
88 | | - uses: actions/cache@v3 |
89 | | - with: |
90 | | - path: /tmp/.buildx-cache |
91 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
92 | | - restore-keys: ${{ runner.os }}-buildx |
93 | | - |
94 | | - - name: Get Tag Version |
95 | | - id: tag2 |
96 | | - run: | |
97 | | - VERSION=${GITHUB_REF#refs/tags/v} |
98 | | - echo "Version to be used: $VERSION" |
99 | | - echo "VERSION=$VERSION" >> $GITHUB_ENV |
100 | | -
|
101 | | - - name: Build and push |
102 | | - id: docker_build |
103 | | - uses: docker/build-push-action@v5 |
104 | | - with: |
105 | | - context: . |
106 | | - file: ./Dockerfile.prod |
107 | | - push: true |
108 | | - tags: | |
109 | | - ${{ secrets.DOCKER_HUB_REPOSITORY }}:${{ env.VERSION }} |
110 | | - ${{ secrets.DOCKER_HUB_REPOSITORY }}:latest |
111 | | - cache-from: type=local,src=/tmp/.buildx-cache |
112 | | - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new |
113 | | - |
114 | | - - name: Refresh Cache |
115 | | - run: | |
116 | | - rm -rf /tmp/.buildx-cache |
117 | | - mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
118 | | -
|
119 | | - - name: Image digest |
120 | | - run: echo ${{ steps.docker_build.outputs.digest }} |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | +jobs: |
| 12 | + build-push-ghcr: |
| 13 | + uses: ClubCedille/cedille-workflows/.github/workflows/build-push-ghcr.yaml@master |
| 14 | + with: |
| 15 | + container-name: ${{ github.event.repository.name }} |
| 16 | + secrets: inherit |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
0 commit comments