|
| 1 | +name: Publish Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on push to default branch |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - master |
| 9 | + |
| 10 | + # Run when a release is created |
| 11 | + release: |
| 12 | + types: [released] |
| 13 | + |
| 14 | +jobs: |
| 15 | + docker: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Docker meta |
| 19 | + id: meta |
| 20 | + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 |
| 21 | + with: |
| 22 | + # list of Docker images to use as base name for tags |
| 23 | + images: | |
| 24 | + plus3it/tardigrade-ci |
| 25 | + ghcr.io/plus3it/tardigrade-ci |
| 26 | + flavor: | |
| 27 | + latest=false |
| 28 | + # generate Docker tags based on the following events/attributes |
| 29 | + tags: | |
| 30 | + # set latest tag for default branch |
| 31 | + type=raw,value=latest,enable={{is_default_branch}} |
| 32 | + # set version tags for releases |
| 33 | + type=semver,pattern={{version}} |
| 34 | + type=semver,pattern={{major}}.{{minor}} |
| 35 | + type=semver,pattern={{major}} |
| 36 | +
|
| 37 | + - name: Login to Docker Hub |
| 38 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 |
| 39 | + with: |
| 40 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 41 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Login to GitHub Container Registry |
| 44 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.repository_owner }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Set up QEMU |
| 51 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 |
| 52 | + |
| 53 | + - name: Set up Docker Buildx |
| 54 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 |
| 55 | + |
| 56 | + - name: Build and push |
| 57 | + uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 |
| 58 | + with: |
| 59 | + push: true |
| 60 | + tags: ${{ steps.meta.outputs.tags }} |
| 61 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments