|
| 1 | +name: Publish Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + branch: |
| 10 | + description: 'Branch to run the action on' |
| 11 | + default: 'main' |
| 12 | + required: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build_and_publish_platform_containers: |
| 16 | + name: Build and publish platform containers |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + packages: write |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + platform: |
| 24 | + - linux/amd64 |
| 25 | + - linux/arm64 |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Set up QEMU |
| 33 | + uses: docker/setup-qemu-action@v3 |
| 34 | + |
| 35 | + - name: Login to DockerHub |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 39 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Login to GitHub Container Registry |
| 42 | + uses: docker/login-action@v3 |
| 43 | + with: |
| 44 | + registry: ghcr.io |
| 45 | + username: ${{ github.repository_owner }} |
| 46 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Build the docker image |
| 49 | + env: |
| 50 | + BUILD_PLATFORM: ${{ matrix.platform == 'linux/arm64' && 'arm64' || 'amd64' }} |
| 51 | + run: | |
| 52 | + APP_VERSION="$(git name-rev --tags --name-only $(git rev-parse HEAD) | head -n 1 | sed 's/\^0//')" |
| 53 | + GIT_SHA="$(git rev-parse HEAD)" |
| 54 | +
|
| 55 | + docker build \ |
| 56 | + -f ./docker/Dockerfile \ |
| 57 | + --progress=plain \ |
| 58 | + -t "ossapps/splitpro-$BUILD_PLATFORM:latest" \ |
| 59 | + -t "ossapps/splitpro-$BUILD_PLATFORM:$GIT_SHA" \ |
| 60 | + -t "ossapps/splitpro-$BUILD_PLATFORM:$APP_VERSION" \ |
| 61 | + -t "ghcr.io/oss-apps/splitpro-$BUILD_PLATFORM:latest" \ |
| 62 | + -t "ghcr.io/oss-apps/splitpro-$BUILD_PLATFORM:$GIT_SHA" \ |
| 63 | + -t "ghcr.io/oss-apps/splitpro-$BUILD_PLATFORM:$APP_VERSION" \ |
| 64 | + . |
| 65 | +
|
| 66 | + - name: Push the docker image to DockerHub |
| 67 | + run: docker push --all-tags "ossapps/splitpro-$BUILD_PLATFORM" |
| 68 | + env: |
| 69 | + BUILD_PLATFORM: ${{ matrix.platform == 'linux/arm64' && 'arm64' || 'amd64' }} |
| 70 | + |
| 71 | + - name: Push the docker image to GitHub Container Registry |
| 72 | + run: docker push --all-tags "ghcr.io/oss-apps/splitpro-$BUILD_PLATFORM" |
| 73 | + env: |
| 74 | + BUILD_PLATFORM: ${{ matrix.platform == 'linux/arm64' && 'arm64' || 'amd64' }} |
| 75 | + |
| 76 | + create_and_publish_manifest: |
| 77 | + name: Create and publish manifest |
| 78 | + runs-on: ubuntu-latest |
| 79 | + permissions: |
| 80 | + packages: write |
| 81 | + needs: build_and_publish_platform_containers |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + fetch-depth: 0 |
| 87 | + |
| 88 | + - name: Login to DockerHub |
| 89 | + uses: docker/login-action@v3 |
| 90 | + with: |
| 91 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 93 | + |
| 94 | + - name: Login to GitHub Container Registry |
| 95 | + uses: docker/login-action@v3 |
| 96 | + with: |
| 97 | + registry: ghcr.io |
| 98 | + username: ${{ github.repository_owner }} |
| 99 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Create and push DockerHub manifest |
| 102 | + run: | |
| 103 | + APP_VERSION="$(git name-rev --tags --name-only $(git rev-parse HEAD) | head -n 1 | sed 's/\^0//')" |
| 104 | + GIT_SHA="$(git rev-parse HEAD)" |
| 105 | +
|
| 106 | + docker manifest create \ |
| 107 | + ossapps/splitpro:latest \ |
| 108 | + --amend ossapps/splitpro-amd64:latest \ |
| 109 | + --amend ossapps/splitpro-arm64:latest \ |
| 110 | +
|
| 111 | + docker manifest create \ |
| 112 | + ossapps/splitpro:$GIT_SHA \ |
| 113 | + --amend ossapps/splitpro-amd64:$GIT_SHA \ |
| 114 | + --amend ossapps/splitpro-arm64:$GIT_SHA \ |
| 115 | +
|
| 116 | + docker manifest create \ |
| 117 | + ossapps/splitpro:$APP_VERSION \ |
| 118 | + --amend ossapps/splitpro-amd64:$APP_VERSION \ |
| 119 | + --amend ossapps/splitpro-arm64:$APP_VERSION \ |
| 120 | +
|
| 121 | + docker manifest push ossapps/splitpro:latest |
| 122 | + docker manifest push ossapps/splitpro:$GIT_SHA |
| 123 | + docker manifest push ossapps/splitpro:$APP_VERSION |
| 124 | +
|
| 125 | + - name: Create and push Github Container Registry manifest |
| 126 | + run: | |
| 127 | + APP_VERSION="$(git name-rev --tags --name-only $(git rev-parse HEAD) | head -n 1 | sed 's/\^0//')" |
| 128 | + GIT_SHA="$(git rev-parse HEAD)" |
| 129 | +
|
| 130 | + docker manifest create \ |
| 131 | + ghcr.io/oss-apps/splitpro:latest \ |
| 132 | + --amend ghcr.io/oss-apps/splitpro-amd64:latest \ |
| 133 | + --amend ghcr.io/oss-apps/splitpro-arm64:latest \ |
| 134 | +
|
| 135 | + docker manifest create \ |
| 136 | + ghcr.io/oss-apps/splitpro:$GIT_SHA \ |
| 137 | + --amend ghcr.io/oss-apps/splitpro-amd64:$GIT_SHA \ |
| 138 | + --amend ghcr.io/oss-apps/splitpro-arm64:$GIT_SHA \ |
| 139 | +
|
| 140 | + docker manifest create \ |
| 141 | + ghcr.io/oss-apps/splitpro:$APP_VERSION \ |
| 142 | + --amend ghcr.io/oss-apps/splitpro-amd64:$APP_VERSION \ |
| 143 | + --amend ghcr.io/oss-apps/splitpro-arm64:$APP_VERSION \ |
| 144 | +
|
| 145 | + docker manifest push ghcr.io/oss-apps/splitpro:latest |
| 146 | + docker manifest push ghcr.io/oss-apps/splitpro:$GIT_SHA |
| 147 | + docker manifest push ghcr.io/oss-apps/splitpro:$APP_VERSION |
0 commit comments