|
1 | 1 | name: Build docker images |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | -# branches: |
6 | | -# - "**" |
7 | | - tags: |
8 | | - - "v*.*.*" |
9 | | - # pull_request: |
| 4 | + push: |
| 5 | + branches: # At least when doing some tests |
| 6 | + - "**" |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + # pull_request: |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - multi-registries: |
13 | | - runs-on: ubuntu-20.04 |
14 | | - steps: |
15 | | - - name: Checkout |
16 | | - uses: actions/checkout@v3 |
17 | | - - name: Docker meta |
18 | | - id: docker_meta |
19 | | - uses: crazy-max/ghaction-docker-meta@v4 |
20 | | - with: |
21 | | - images: fclairamb/ftpserver |
22 | | - - name: Set up QEMU |
23 | | - uses: docker/setup-qemu-action@v2 |
24 | | - - name: Set up Docker Buildx |
25 | | - uses: docker/setup-buildx-action@v2 |
26 | | - - name: Cache Docker layers |
27 | | - uses: actions/cache@v3 |
28 | | - with: |
29 | | - path: /tmp/.buildx-cache |
30 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
31 | | - restore-keys: | |
32 | | - ${{ runner.os }}-buildx- |
33 | | - - name: Login to DockerHub |
34 | | - if: github.repository == 'fclairamb/ftpserver' |
35 | | - uses: docker/login-action@v2 |
36 | | - with: |
37 | | - username: ${{ github.repository_owner }} |
38 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
39 | | - - name: Login to GitHub Container Registry |
40 | | - if: github.repository == 'fclairamb/ftpserver' |
41 | | - uses: docker/login-action@v2 |
42 | | - with: |
43 | | - registry: ghcr.io |
44 | | - username: ${{ github.repository_owner }} |
45 | | - password: ${{ secrets.CR_PAT }} |
46 | | - - name: Build and push |
47 | | - uses: docker/build-push-action@v3 |
48 | | - with: |
49 | | - context: . |
50 | | - file: ./Dockerfile |
51 | | - platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64 |
52 | | - push: ${{ github.repository == 'fclairamb/ftpserver' }} |
53 | | - tags: ${{ steps.docker_meta.outputs.tags }} |
54 | | - labels: ${{ steps.docker_meta.outputs.labels }} |
55 | | - cache-from: type=local,src=/tmp/.buildx-cache |
56 | | - cache-to: type=local,dest=/tmp/.buildx-cache |
| 12 | + build-and-push: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + type: ["", "alpine"] |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + - name: Setup go |
| 23 | + uses: actions/setup-go@v3 |
| 24 | + with: |
| 25 | + go-version: 1.19 |
| 26 | + - name: Change version |
| 27 | + run: | |
| 28 | + curl -L https://github.com/fclairamb/ci-info/releases/download/v0.4.4/ci-info_0.4.4_linux_amd64.tar.gz | tar -zx |
| 29 | + ./ci-info |
| 30 | + - name: Docker meta |
| 31 | + id: docker_meta |
| 32 | + uses: docker/metadata-action@v4 |
| 33 | + with: |
| 34 | + images: | |
| 35 | + fclairamb/ftpserver |
| 36 | + ghcr.io/fclairamb/ftpserver |
| 37 | + flavor: | |
| 38 | + suffix=${{ matrix.type != '' && format('-{0}', matrix.type) || '' }} |
| 39 | + latest=false |
| 40 | + tags: | |
| 41 | + type=semver,pattern={{version}} |
| 42 | + type=semver,pattern={{major}}.{{minor}} |
| 43 | + type=semver,pattern={{major}} |
| 44 | + type=semver,suffix=,pattern=${{ matrix.type != '' && matrix.type || 'latest' }} |
| 45 | + type=ref,event=branch |
| 46 | + type=ref,event=pr |
| 47 | + - name: Set up QEMU |
| 48 | + uses: docker/setup-qemu-action@v2 |
| 49 | + - name: Set up Docker Buildx |
| 50 | + uses: docker/setup-buildx-action@v2 |
| 51 | + - name: Cache Docker layers |
| 52 | + uses: actions/cache@v3 |
| 53 | + with: |
| 54 | + path: /tmp/.buildx-cache |
| 55 | + key: ${{ runner.os }}-buildx-${{ matrix.type }}-${{ github.sha }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-buildx- |
| 58 | + - name: Login to DockerHub |
| 59 | + if: github.repository == 'fclairamb/ftpserver' |
| 60 | + uses: docker/login-action@v2 |
| 61 | + with: |
| 62 | + username: ${{ github.repository_owner }} |
| 63 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 64 | + - name: Login to GitHub Container Registry |
| 65 | + if: github.repository == 'fclairamb/ftpserver' |
| 66 | + uses: docker/login-action@v2 |
| 67 | + with: |
| 68 | + registry: ghcr.io |
| 69 | + username: ${{ github.repository_owner }} |
| 70 | + password: ${{ secrets.CR_PAT }} |
| 71 | + - name: Build and push (scratch) |
| 72 | + uses: docker/build-push-action@v3 |
| 73 | + with: |
| 74 | + context: . |
| 75 | + file: ./Dockerfile${{ matrix.type != '' && format('.{0}', matrix.type) || '' }} |
| 76 | + platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 |
| 77 | + push: ${{ github.repository == 'fclairamb/ftpserver' }} |
| 78 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 79 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 80 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 81 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 82 | + |
| 83 | + build-and-push-status: |
| 84 | + needs: build-and-push |
| 85 | + runs-on: ubuntu-22.04 |
| 86 | + steps: |
| 87 | + - run: echo 'All good' |
0 commit comments