|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["**"] |
| 6 | + tags: ["**"] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build ${{ matrix.service }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + service: |
| 16 | + - correctedforecaster |
| 17 | + - healthz |
| 18 | + - jsonfrontend |
| 19 | + - moxfrontend |
| 20 | + - rawdataforecaster |
| 21 | + - xmlfrontend |
| 22 | + env: |
| 23 | + IMAGE: fortiregistry.azurecr.io/${{ matrix.service }}:${{ github.run_id }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Log in to Azure Container Registry |
| 28 | + run: docker login -u ${{ secrets.AZURE_REGISTRY_USERNAME }} -p ${{ secrets.AZURE_REGISTRY_PASSWORD }} fortiregistry.azurecr.io |
| 29 | + |
| 30 | + - name: Build and push |
| 31 | + run: | |
| 32 | + docker build -t $IMAGE -f ${{ matrix.service }}/build/package/Dockerfile . |
| 33 | + docker push $IMAGE |
| 34 | +
|
| 35 | + fortiup: |
| 36 | + name: Build fortiup |
| 37 | + runs-on: ubuntu-latest |
| 38 | + if: startsWith(github.ref, 'refs/tags/fortiup') |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + # Produce a filesystem-safe slug from the tag name (e.g. fortiup/0.4.0 -> fortiup-0-4-0), |
| 43 | + # mirroring GitLab's $CI_COMMIT_REF_SLUG behaviour. |
| 44 | + - name: Create ref slug |
| 45 | + id: slug |
| 46 | + run: echo "slug=$(echo '${{ github.ref_name }}' | tr '/.' '-')" >> "$GITHUB_OUTPUT" |
| 47 | + |
| 48 | + - name: Build image and extract binary |
| 49 | + env: |
| 50 | + IMAGE: fortiregistry.azurecr.io/fortiup:${{ github.run_id }} |
| 51 | + run: | |
| 52 | + docker build -t $IMAGE -f fortiup/build/package/Dockerfile . |
| 53 | + docker run --rm --entrypoint cat $IMAGE /usr/local/bin/fortiup > ${{ steps.slug.outputs.slug }} |
| 54 | + chmod +x ${{ steps.slug.outputs.slug }} |
| 55 | +
|
| 56 | + - name: Upload binary artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: ${{ steps.slug.outputs.slug }} |
| 60 | + path: ${{ steps.slug.outputs.slug }} |
| 61 | + |
| 62 | + vulncheck: |
| 63 | + name: Vulnerability check |
| 64 | + needs: [build] |
| 65 | + runs-on: ubuntu-latest |
| 66 | + container: |
| 67 | + # Requires AZURE_REGISTRY_USERNAME and AZURE_REGISTRY_PASSWORD secrets to pull the image. |
| 68 | + # Build/push the devcontainer image via the devcontainer.yml workflow when it changes. |
| 69 | + image: fortiregistry.azurecr.io/devcontainer:latest |
| 70 | + credentials: |
| 71 | + username: ${{ secrets.AZURE_REGISTRY_USERNAME }} |
| 72 | + password: ${{ secrets.AZURE_REGISTRY_PASSWORD }} |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + - run: govulncheck ./... |
| 76 | + |
| 77 | + # trivy-scan: |
| 78 | + # name: Trivy Dockerfile scan |
| 79 | + # needs: [build] |
| 80 | + # runs-on: ubuntu-latest |
| 81 | + # container: |
| 82 | + # image: aquasec/trivy |
| 83 | + # steps: |
| 84 | + # - uses: actions/checkout@v4 |
| 85 | + # - name: Scan all Dockerfiles |
| 86 | + # run: | |
| 87 | + # for dockerfile in */build/package/Dockerfile; do |
| 88 | + # echo "Scanning $dockerfile" |
| 89 | + # trivy fs --exit-code 1 --severity MEDIUM,HIGH,CRITICAL \ |
| 90 | + # --scanners vuln,secret,license,misconfig "$dockerfile" |
| 91 | + # done |
0 commit comments