|
| 1 | +name: 'build stable images' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 7 | + |
| 8 | +# TODO: only request needed permissions |
| 9 | +permissions: write-all |
| 10 | + |
| 11 | +jobs: |
| 12 | + docker: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + env: |
| 15 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 16 | + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 17 | + # support dockerhub organizations. If none is present, use the dockerhub username |
| 18 | + DOCKERHUB_ORGANIZATION: ${{ secrets.DOCKERHUB_ORGANIZATION == null && secrets.DOCKERHUB_USERNAME || secrets.DOCKERHUB_ORGANIZATION }} |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Set env |
| 22 | + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 23 | + |
| 24 | + - name: Set up QEMU |
| 25 | + uses: docker/setup-qemu-action@v3 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v3 |
| 29 | + |
| 30 | + - name: Login to Docker Hub |
| 31 | + uses: docker/login-action@v3 |
| 32 | + if: env.DOCKERHUB_USERNAME != null |
| 33 | + with: |
| 34 | + username: ${{ env.DOCKERHUB_USERNAME }} |
| 35 | + password: ${{ env.DOCKERHUB_PASSWORD }} |
| 36 | + |
| 37 | + - name: Login to GitHub Container Registry |
| 38 | + uses: docker/login-action@v3 |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + username: ${{ github.actor }} |
| 42 | + password: ${{ github.token }} |
| 43 | + |
| 44 | + - id: lowercase-repository |
| 45 | + name: lowercase repository |
| 46 | + uses: ASzc/change-string-case-action@v6 |
| 47 | + with: |
| 48 | + string: ${{ github.repository }} |
| 49 | + |
| 50 | + - name: Build and push (GHCR only) |
| 51 | + uses: docker/build-push-action@v5 |
| 52 | + if: env.DOCKERHUB_ORGANIZATION == null |
| 53 | + with: |
| 54 | + context: . |
| 55 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 56 | + push: true |
| 57 | + tags: | |
| 58 | + ghcr.io/${{ steps.lowercase-repository.outputs.lowercase }}/saic-python-api-proxy:latest |
| 59 | + ghcr.io/${{ steps.lowercase-repository.outputs.lowercase }}/saic-python-api-proxy:${{ env.RELEASE_VERSION }} |
| 60 | +
|
| 61 | + - name: Build and push (GHCR + DockerHub) |
| 62 | + uses: docker/build-push-action@v5 |
| 63 | + if: env.DOCKERHUB_ORGANIZATION != null |
| 64 | + with: |
| 65 | + context: . |
| 66 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 67 | + push: true |
| 68 | + tags: | |
| 69 | + ghcr.io/${{ steps.lowercase-repository.outputs.lowercase }}/saic-python-api-proxy:latest |
| 70 | + ghcr.io/${{ steps.lowercase-repository.outputs.lowercase }}/saic-python-api-proxy:${{ env.RELEASE_VERSION }} |
| 71 | + ${{ secrets.DOCKERHUB_ORGANIZATION != null && format('{0}/saic-python-api-proxy:latest', secrets.DOCKERHUB_ORGANIZATION)}} |
| 72 | + ${{ secrets.DOCKERHUB_ORGANIZATION != null && format('{0}/saic-python-api-proxy:{1}', secrets.DOCKERHUB_ORGANIZATION, env.RELEASE_VERSION)}} |
0 commit comments