Docker #14
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: Docker | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| docker: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Extract version from Cargo.toml | |
| id: cargo-version | |
| run: | | |
| VERSION=v$(grep -m1 "^version" Cargo.toml | cut -d'"' -f2) | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Check there is no existing image with the same version | |
| run: | | |
| if docker manifest inspect ghcr.io/gyulyvgc/sniffnet:${{ env.VERSION }}; then | |
| echo "Image with version ${{ env.VERSION }} already exists" | |
| exit 1 | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: GyulyVGC | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ghcr.io/gyulyvgc/sniffnet:latest | |
| ghcr.io/gyulyvgc/sniffnet:${{ env.VERSION }} |