File: container.yml

package info (click to toggle)
ospd-openvas 22.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,664 kB
  • sloc: python: 14,268; xml: 1,913; makefile: 45; sh: 29
file content (80 lines) | stat: -rw-r--r-- 3,173 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Container Image Builds

on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
    branches: [main]
  workflow_dispatch:

jobs:
  production:
    name: Production Images
    runs-on: self-hosted-generic
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - uses: greenbone/actions/is-latest-tag@v3
        id: latest
      - name: Set container build options
        id: container-opts
        run: |
          if [[ "${{ github.ref_type }}" = 'tag' ]]; then
            echo "version=stable" >> $GITHUB_OUTPUT
          else
            echo "version=edge" >> $GITHUB_OUTPUT
          fi
      - name: 'Setup meta information (IS_LATEST_TAG: ${{ steps.latest.outputs.is-latest-tag }} )'
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ github.repository }}
          labels: |
            org.opencontainers.image.vendor=Greenbone
            org.opencontainers.image.base.name=greenbone/openvas-scanner
          flavor: latest=false # no auto latest container tag for git tags
          tags: |
            # when IS_LATEST_TAG is set create a stable and a latest tag
            type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
            type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
            # if tag version is set than create a version tags
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            # if we are on the main branch set edge
            type=edge,branch=main
            # use branch-sha otherwise for pushes to branches other then main (will not be uploaded)
            type=raw,value={{branch}}-{{sha}},enable=${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name != 'main' }}
            # use pr-$PR_ID for pull requests (will not be uploaded)
            type=ref,event=pr
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Login to Docker Registry
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Set up Go modules cache
        uses: actions/cache@v5
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
            key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
            restore-keys: |
              ${{ runner.os }}-go-
      - name: Build and push Container image
        uses: docker/build-push-action@v6
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }}
          file: .docker/prod.Dockerfile
          platforms: linux/amd64,linux/arm64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            VERSION=${{ steps.container-opts.outputs.version }}