diff options
| author | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-09 16:38:56 +0100 |
|---|---|---|
| committer | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-09 16:45:30 +0100 |
| commit | 62530eabfb8a7d278d570a8ee5375e6c67717fbb (patch) | |
| tree | 8f663b4f9caa8b24144105efc28a5f14c9802eaa | |
| parent | eed19a93a29624ae0332d46a04cdc940b97ec8a0 (diff) | |
| download | containerspy-62530eabfb8a7d278d570a8ee5375e6c67717fbb.tar.gz containerspy-62530eabfb8a7d278d570a8ee5375e6c67717fbb.tar.bz2 containerspy-62530eabfb8a7d278d570a8ee5375e6c67717fbb.zip | |
add deploy CI
| -rw-r--r-- | .github/workflows/publish.yml | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6ab5170 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,61 @@ +name: Publish Docker Image + +on: + push: + branches: + - master + tags: + - v** + workflow_dispatch: + +jobs: + publish: + name: Publish Docker Image to ghcr.io + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Setup version number + run: | + # docker/build-push-action supports comma separated tags + DOCKER_IMAGE_TAG_BASE="ghcr.io/${{ github.repository }}" + DOCKER_IMAGE_TAGS="$DOCKER_IMAGE_TAG_BASE:dev" + + # if this is a versioned release, github.ref will start with 'refs/tags/v' + GH_REF="${{ github.ref }}" + # cut off 'refs/tags/v' + if [[ $GH_REF == "refs/tags/v"* ]]; then + VERSION=$(echo $GH_REF | cut -c 12-) + DOCKER_IMAGE_TAGS="$DOCKER_IMAGE_TAGS,$DOCKER_IMAGE_TAG_BASE:latest,$DOCKER_IMAGE_TAG_BASE:$VERSION" + fi + + echo "DOCKER_IMAGE_TAGS=\"$DOCKER_IMAGE_TAGS\"" >> $GITHUB_ENV + + - name: Check if version already exists in registry + run: | + if docker manifest inspect ghcr.io/${{ github.repository }}:$VERSION > /dev/null 2>&1; then + echo "Image with version $VERSION already exists in registry" + exit 1 + fi + + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker Image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.DOCKER_IMAGE_TAGS }} + platforms: linux/amd64,linux/arm64,linux/arm/v7
\ No newline at end of file |
