|
1 | 1 | name: Build and Push to Docker Hub |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | | - tags: |
8 | | - - "v*" |
9 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + workflow_dispatch: |
10 | 10 |
|
11 | 11 | env: |
12 | | - DOCKER_USERNAME: ${{ github.actor }} |
| 12 | + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
13 | 13 |
|
14 | 14 | jobs: |
15 | | - build-and-push: |
16 | | - runs-on: ubuntu-latest |
17 | | - strategy: |
18 | | - matrix: |
19 | | - include: |
20 | | - - dockerfile: ./backend/Dockerfile |
21 | | - image: nachweise-backend |
22 | | - context: ./backend |
23 | | - - dockerfile: ./client-nachweise/Dockerfile |
24 | | - image: nachweise-frontend |
25 | | - context: ./client-nachweise |
26 | | - |
27 | | - steps: |
28 | | - - name: Checkout repository |
29 | | - uses: actions/checkout@v4 |
30 | | - |
31 | | - - name: Set up Docker Buildx |
32 | | - uses: docker/setup-buildx-action@v3 |
33 | | - |
34 | | - - name: Log in to Docker Hub |
35 | | - uses: docker/login-action@v3 |
36 | | - with: |
37 | | - username: ${{ github.actor }} |
38 | | - password: ${{ secrets.GITHUB_TOKEN }} |
39 | | - |
40 | | - - name: Extract metadata |
41 | | - id: meta |
42 | | - uses: docker/metadata-action@v5 |
43 | | - with: |
44 | | - images: ${{ env.DOCKER_USERNAME }}/${{ matrix.image }} |
45 | | - tags: | |
46 | | - type=ref,event=branch |
47 | | - type=semver,pattern={{version}} |
48 | | - type=semver,pattern={{major}}.{{minor}} |
49 | | - type=sha,prefix={{branch}}- |
50 | | - type=raw,value=latest,enable={{is_default_branch}} |
51 | | -
|
52 | | - - name: Build and push |
53 | | - uses: docker/build-push-action@v5 |
54 | | - with: |
55 | | - context: ${{ matrix.context }} |
56 | | - push: true |
57 | | - tags: ${{ steps.meta.outputs.tags }} |
58 | | - labels: ${{ steps.meta.outputs.labels }} |
59 | | - cache-from: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ matrix.image }}:buildcache |
60 | | - cache-to: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ matrix.image }}:buildcache,mode=max |
| 15 | + build-and-push: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - dockerfile: ./backend/Dockerfile |
| 21 | + image: nachweise-backend |
| 22 | + context: ./backend |
| 23 | + - dockerfile: ./client-nachweise/Dockerfile |
| 24 | + image: nachweise-frontend |
| 25 | + context: ./client-nachweise |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up Docker Buildx |
| 32 | + uses: docker/setup-buildx-action@v3 |
| 33 | + |
| 34 | + - name: Log in to Docker Hub |
| 35 | + uses: docker/login-action@v3 |
| 36 | + with: |
| 37 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 38 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Extract metadata |
| 41 | + id: meta |
| 42 | + uses: docker/metadata-action@v5 |
| 43 | + with: |
| 44 | + images: ${{ env.DOCKER_USERNAME }}/${{ matrix.image }} |
| 45 | + tags: | |
| 46 | + type=ref,event=branch |
| 47 | + type=semver,pattern={{version}} |
| 48 | + type=semver,pattern={{major}}.{{minor}} |
| 49 | + type=sha,prefix={{branch}}- |
| 50 | + type=raw,value=latest,enable={{is_default_branch}} |
| 51 | +
|
| 52 | + - name: Build and push |
| 53 | + uses: docker/build-push-action@v5 |
| 54 | + with: |
| 55 | + context: ${{ matrix.context }} |
| 56 | + push: true |
| 57 | + tags: ${{ steps.meta.outputs.tags }} |
| 58 | + labels: ${{ steps.meta.outputs.labels }} |
| 59 | + cache-from: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ matrix.image }}:buildcache |
| 60 | + cache-to: type=registry,ref=${{ env.DOCKER_USERNAME }}/${{ matrix.image }}:buildcache,mode=max |
0 commit comments