|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + tags: |
| 8 | + - '*.*.*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - 'master' |
| 12 | + |
| 13 | +jobs: |
| 14 | + docker: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - |
| 18 | + name: Checkout |
| 19 | + uses: actions/checkout@v3 |
| 20 | + - |
| 21 | + name: Docker meta |
| 22 | + id: meta |
| 23 | + uses: docker/metadata-action@v4 |
| 24 | + with: |
| 25 | + # list of Docker images to use as base name for tags |
| 26 | + images: | |
| 27 | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} |
| 28 | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
| 29 | + # generate Docker tags based on the following events/attributes |
| 30 | + tags: | |
| 31 | + type=schedule |
| 32 | + type=ref,event=branch |
| 33 | + type=ref,event=pr |
| 34 | + type=semver,pattern={{version}} |
| 35 | + type=semver,pattern={{major}}.{{minor}} |
| 36 | + type=semver,pattern={{major}} |
| 37 | + type=sha |
| 38 | +# - |
| 39 | +# name: Set up QEMU |
| 40 | +# uses: docker/setup-qemu-action@v2 |
| 41 | + - |
| 42 | + name: Set up Docker Buildx |
| 43 | + uses: docker/setup-buildx-action@v2 |
| 44 | + - |
| 45 | + name: Login to Docker Hub |
| 46 | + if: github.event_name != 'pull_request' |
| 47 | + uses: docker/login-action@v2 |
| 48 | + with: |
| 49 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 50 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 51 | + - |
| 52 | + name: Login to GHCR |
| 53 | + if: github.event_name != 'pull_request' |
| 54 | + uses: docker/login-action@v2 |
| 55 | + with: |
| 56 | + registry: ghcr.io |
| 57 | + username: ${{ github.repository_owner }} |
| 58 | + password: ${{ secrets.GIT_PACKAGES_TOKEN }} |
| 59 | + - |
| 60 | + name: Build and push |
| 61 | + uses: docker/build-push-action@v3 |
| 62 | + with: |
| 63 | + context: . |
| 64 | + push: ${{ github.event_name != 'pull_request' }} |
| 65 | + tags: ${{ steps.meta.outputs.tags }} |
| 66 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments