|
| 1 | +name: Publish Preview Docker Image |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths-ignore: |
| 5 | + - '.devcontainer/*' |
| 6 | + - '.github/*.yml' |
| 7 | + - '.github/workflows/publish_codespace.yml' |
| 8 | + - '.github/workflows/publish_release.yml' |
| 9 | + - '.github/workflows/publish_nightly.yml' |
| 10 | + - '*.md' |
| 11 | + - '.*' |
| 12 | + - 'LICENSE' |
| 13 | + - 'Guardfile' |
| 14 | + - Aptfile |
| 15 | + - 'Procfile*' |
| 16 | + - '*.yaml' |
| 17 | + branches: |
| 18 | + - 'release/*' |
| 19 | + |
| 20 | +env: |
| 21 | + DOCKER_TAG: preview |
| 22 | + |
| 23 | +jobs: |
| 24 | + push_to_registry: |
| 25 | + name: Push Docker image to multiple registries |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + packages: write |
| 29 | + contents: read |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up QEMU |
| 35 | + uses: docker/setup-qemu-action@v3 |
| 36 | + |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + |
| 40 | + - name: Get release version |
| 41 | + id: release_version |
| 42 | + run: | |
| 43 | + echo "RELEASE_VERSION=$(grep -oP "VERSION = '\K[^']*" config/application.rb)" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Login to Docker Hub |
| 46 | + uses: docker/login-action@v3 |
| 47 | + with: |
| 48 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 49 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 50 | + |
| 51 | + - name: Login to GitHub Container Registry |
| 52 | + uses: docker/login-action@v3 |
| 53 | + with: |
| 54 | + registry: ghcr.io |
| 55 | + username: ${{ github.actor }} |
| 56 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + - name: Docker metadata |
| 59 | + id: metadata |
| 60 | + uses: docker/metadata-action@v5 |
| 61 | + with: |
| 62 | + images: | |
| 63 | + ${{ github.repository }} |
| 64 | + ghcr.io/${{ github.repository }} |
| 65 | + tags: | |
| 66 | + type=raw,value=${{ steps.release_version.outputs.RELEASE_VERSION }}-${{ env.DOCKER_TAG }} |
| 67 | +
|
| 68 | + - name: Build and Push |
| 69 | + uses: docker/build-push-action@v6 |
| 70 | + with: |
| 71 | + context: . |
| 72 | + push: true |
| 73 | + labels: ${{ steps.metadata.outputs.labels }} |
| 74 | + tags: ${{ steps.metadata.outputs.tags }} |
| 75 | + annotations: ${{ steps.metadata.outputs.annotations }} |
| 76 | + platforms: linux/amd64,linux/arm64 |
| 77 | + build-args: | |
| 78 | + REPLACE_CHINA_MIRROR=false |
| 79 | + VCS_REF=${{ github.sha }} |
| 80 | + TAG=${{ env.DOCKER_TAG }} |
| 81 | + BUILD_DATE=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.created'] }} |
0 commit comments