|  | 
|  | 1 | +name: Publish Container Images | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  push: | 
|  | 5 | +    branches: | 
|  | 6 | +      - main | 
|  | 7 | +    tags: | 
|  | 8 | +      - v[0-9]+.[0-9]+.[0-9]+ | 
|  | 9 | +  pull_request: | 
|  | 10 | + | 
|  | 11 | +concurrency: | 
|  | 12 | +  group: ${{ github.workflow }}-${{ github.ref }} | 
|  | 13 | +  cancel-in-progress: true | 
|  | 14 | + | 
|  | 15 | +permissions: | 
|  | 16 | +  contents: read | 
|  | 17 | +  packages: write | 
|  | 18 | + | 
|  | 19 | +jobs: | 
|  | 20 | +  build-and-push: | 
|  | 21 | +    name: Build and Push (${{ matrix.image }}) | 
|  | 22 | +    runs-on: ubuntu-latest | 
|  | 23 | +    strategy: | 
|  | 24 | +      matrix: | 
|  | 25 | +        image: [ | 
|  | 26 | +          device-injector, | 
|  | 27 | +          differ, | 
|  | 28 | +          hook-injector, | 
|  | 29 | +          logger, | 
|  | 30 | +          network-device-injector, | 
|  | 31 | +          network-logger, | 
|  | 32 | +          template, | 
|  | 33 | +          ulimit-adjuster, | 
|  | 34 | +          v010-adapter, | 
|  | 35 | +        ] | 
|  | 36 | + | 
|  | 37 | +    steps: | 
|  | 38 | +      - name: Checkout code | 
|  | 39 | +        uses: actions/checkout@v4 | 
|  | 40 | + | 
|  | 41 | +      - name: Set up Docker Buildx | 
|  | 42 | +        uses: docker/setup-buildx-action@v3 | 
|  | 43 | + | 
|  | 44 | +      - name: Log in to registry | 
|  | 45 | +        if: github.event_name == 'push' | 
|  | 46 | +        uses: docker/login-action@v3 | 
|  | 47 | +        with: | 
|  | 48 | +          registry: ghcr.io | 
|  | 49 | +          username: ${{ github.actor }} | 
|  | 50 | +          password: ${{ secrets.GITHUB_TOKEN }} | 
|  | 51 | + | 
|  | 52 | +      - name: Determine image tag name | 
|  | 53 | +        id: tag | 
|  | 54 | +        run: | | 
|  | 55 | +          if [ "${{ github.ref_type }}" = "tag" ]; then | 
|  | 56 | +              tag="${{ github.ref_name }}" | 
|  | 57 | +          else | 
|  | 58 | +              if [ "${{ github.event_name }}" = "pull_request" ]; then | 
|  | 59 | +                  tag="pr-${{ github.event.pull_request.number }}" | 
|  | 60 | +              else | 
|  | 61 | +                  case "${{ github.ref_name }}" in | 
|  | 62 | +                      main) | 
|  | 63 | +                          tag="unstable" | 
|  | 64 | +                          ;; | 
|  | 65 | +                  esac | 
|  | 66 | +              fi | 
|  | 67 | +          fi | 
|  | 68 | +          if [ -z "$tag" ]; then | 
|  | 69 | +              echo "ERROR: failed to determine image tag" | 
|  | 70 | +              exit 1 | 
|  | 71 | +          fi | 
|  | 72 | +          echo "TAG_NAME=$tag" >> $GITHUB_ENV | 
|  | 73 | +
 | 
|  | 74 | +      - name: Build and push image | 
|  | 75 | +        uses: docker/build-push-action@v6 | 
|  | 76 | +        with: | 
|  | 77 | +          context: . | 
|  | 78 | +          file: ./plugins/Dockerfile | 
|  | 79 | +          build-args: | | 
|  | 80 | +            PLUGIN=${{ matrix.image }} | 
|  | 81 | +          push: ${{ github.event_name == 'push' }} | 
|  | 82 | +          platforms: ${{ github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | 
|  | 83 | +          tags: ghcr.io/${{ github.repository }}/plugins/${{ matrix.image }}:${{ env.TAG_NAME }} | 
0 commit comments