|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v[0-9]+.[0-9]+.[0-9]+ |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Set up QEMU |
| 17 | + uses: docker/setup-qemu-action@v1 |
| 18 | + |
| 19 | + - name: Set up Docker Buildx |
| 20 | + uses: docker/setup-buildx-action@v1 |
| 21 | + with: |
| 22 | + version: latest |
| 23 | + buildkitd-flags: --debug |
| 24 | + |
| 25 | + - name: Cache Docker layers |
| 26 | + uses: actions/cache@v2 |
| 27 | + with: |
| 28 | + path: /tmp/.buildx/cache |
| 29 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-buildx- |
| 32 | +
|
| 33 | + - name: Login to DockerHub |
| 34 | + uses: docker/login-action@v1 |
| 35 | + with: |
| 36 | + username: ${{ github.repository_owner }} |
| 37 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 38 | + |
| 39 | + - name: Login to GitHub Container Registry |
| 40 | + uses: docker/login-action@v1 |
| 41 | + with: |
| 42 | + registry: ghcr.io |
| 43 | + username: ${{ github.repository_owner }} |
| 44 | + password: ${{ secrets.GHCR_TOKEN }} |
| 45 | + |
| 46 | + - name: Output version |
| 47 | + id: version |
| 48 | + run: | |
| 49 | + echo ::set-output name=version::${GITHUB_REF##*/} |
| 50 | +
|
| 51 | + - name: Build and push |
| 52 | + uses: docker/build-push-action@v2 |
| 53 | + with: |
| 54 | + push: true |
| 55 | + cache-from: type=local,src=/tmp/.buildx/cache |
| 56 | + cache-to: type=local,dest=/tmp/.buildx/cache,mode=max |
| 57 | + tags: | |
| 58 | + ${{ github.repository }}:latest |
| 59 | + ${{ github.repository }}:${{ steps.version.outputs.version }} |
| 60 | + ghcr.io/${{ github.repository }}:latest |
| 61 | + ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} |
0 commit comments