feat (CI): add new github-docker CI workflow to build, test and push … #1
Workflow file for this run
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, Test & Push images | |
| on: | |
| push: | |
| tags: | |
| - "*.*.*" # e.g., 1.0.0, 2.1.3 | |
| workflow_dispatch: | |
| env: | |
| IMAGE_NAME: ${{ vars.IMAGE_NAME }} | |
| PLATFORMS: ${{ vars.PLATFORMS }} | |
| jobs: | |
| build-test-push: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - variant: debian | |
| dockerfile: ./debian.dockerfile | |
| tag: debian | |
| latest: true | |
| - variant: alpine | |
| dockerfile: ./alpine.dockerfile | |
| tag: alpine | |
| latest: false | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Determine tag name | |
| id: vars | |
| run: echo "VERSION_TAG=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT | |
| - name: Extract OCI metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ matrix.tag }} | |
| type=raw,value=${{ matrix.tag }}-${{ steps.vars.outputs.VERSION_TAG }} | |
| ${{ matrix.latest && format('type=raw,value=latest') || '' }} | |
| labels: | | |
| org.opencontainers.image.title=VNC Browser (${{ matrix.tag }}) | |
| org.opencontainers.image.version=${{ steps.vars.outputs.VERSION_TAG }} | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Build ${{ matrix.variant }} image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| platforms: ${{ env.PLATFORMS }} | |
| push: false | |
| load: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test container startup | |
| run: | | |
| docker run -d --rm --name test-${{ matrix.tag }} \ | |
| -p 5900:5900 -p 6080:6080 \ | |
| -e VNC_PASSWORD=testpass \ | |
| ${{ env.IMAGE_NAME }}:${{ matrix.tag }} | |
| echo "Waiting for container to start..." | |
| sleep 10 | |
| docker ps | |
| curl -sSf http://localhost:6080 > /dev/null | |
| echo "Test passed for ${{ matrix.tag }}" | |
| - name: Push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| platforms: ${{ env.PLATFORMS }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |