ci(release): remove completed tag migration #65
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: docker-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: publish-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Prepare image names | |
| id: images | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| run: | | |
| echo "dockerhub=${DOCKERHUB_USERNAME,,}/subweb" >> "$GITHUB_OUTPUT" | |
| echo "ghcr=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Generate image metadata | |
| id: metadata | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| ${{ steps.images.outputs.dockerhub }} | |
| ${{ steps.images.outputs.ghcr }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} | |
| type=ref,event=tag,enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} | |
| labels: | | |
| org.opencontainers.image.title=SubWeb | |
| org.opencontainers.image.description=Privacy-conscious Subconverter web frontend | |
| - name: Build and push multi-platform image | |
| id: build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.metadata.outputs.tags }} | |
| labels: ${{ steps.metadata.outputs.labels }} | |
| build-args: | | |
| APP_REVISION=${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Verify published platforms | |
| env: | |
| DOCKERHUB_IMAGE: ${{ steps.images.outputs.dockerhub }} | |
| GHCR_IMAGE: ${{ steps.images.outputs.ghcr }} | |
| DIGEST: ${{ steps.build.outputs.digest }} | |
| run: | | |
| for image in "$DOCKERHUB_IMAGE" "$GHCR_IMAGE"; do | |
| docker buildx imagetools inspect "$image@$DIGEST" --raw > manifest.json | |
| jq -e ' | |
| [.manifests[] | |
| | select(.platform.os == "linux") | |
| | select(.platform.architecture == "amd64" or .platform.architecture == "arm64") | |
| | .platform.architecture] | |
| | unique | |
| | sort == ["amd64", "arm64"] | |
| ' manifest.json | |
| done | |
| - name: Smoke-test the published images | |
| env: | |
| DOCKERHUB_IMAGE: ${{ steps.images.outputs.dockerhub }} | |
| GHCR_IMAGE: ${{ steps.images.outputs.ghcr }} | |
| DIGEST: ${{ steps.build.outputs.digest }} | |
| EXPECTED_REVISION: ${{ github.sha }} | |
| run: | | |
| trap 'docker rm --force subweb-smoke >/dev/null 2>&1 || true' EXIT | |
| for image in "$DOCKERHUB_IMAGE" "$GHCR_IMAGE"; do | |
| docker run --detach --name subweb-smoke --publish 18080:80 "$image@$DIGEST" | |
| for attempt in $(seq 1 20); do | |
| if curl --fail --silent --show-error http://127.0.0.1:18080/ >/dev/null; then | |
| break | |
| fi | |
| if [ "$attempt" -eq 20 ]; then | |
| docker logs subweb-smoke | |
| exit 1 | |
| fi | |
| sleep 1 | |
| done | |
| curl --fail --silent --show-error http://127.0.0.1:18080/version.json | | |
| jq -e --arg expected "$EXPECTED_REVISION" '.revision == $expected' | |
| curl --fail --silent --show-error http://127.0.0.1:18080/conf/config.js | | |
| grep --fixed-strings 'enableShortUrl: false' | |
| curl --fail --silent --show-error --head http://127.0.0.1:18080/ | | |
| grep --ignore-case --fixed-strings 'x-content-type-options: nosniff' | |
| docker rm --force subweb-smoke | |
| done |