Retrieve data in fink-alert-schemas #79
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
| # Qserv operator CI workflow | |
| --- | |
| name: "CI" | |
| on: | |
| push: | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| CIUXCONFIG: /tmp/ciux.fink-alert-simulator.sh | |
| CIUX_VERSION: v0.0.4-rc10 | |
| jobs: | |
| build: | |
| name: Build image | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| image: ${{ steps.export.outputs.IMAGE }} | |
| promoted_image: ${{ steps.export.outputs.PROMOTED_IMAGE }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21.4' | |
| - name: Install ciux | |
| run: go install github.com/k8s-school/ciux@"${{ env.CIUX_VERSION }}" | |
| - name: Check dependencies consistency | |
| run: ciux ignite $PWD | |
| - name: Build fink-alert-simulator image | |
| run: | | |
| ./build.sh | |
| - name: Export fink-alert-simulator image | |
| id: export | |
| run: | | |
| # TODO make it simpler! | |
| . $CIUXCONFIG | |
| mkdir -p artifacts | |
| if [ $CIUX_BUILD = true ]; then | |
| echo "Export $CIUX_IMAGE_URL to Github artifact store" | |
| docker save "$CIUX_IMAGE_URL" > artifacts/image.tar | |
| else | |
| echo "Using existing image $CIUX_IMAGE_URL" | |
| touch artifacts/empty | |
| fi | |
| echo "IMAGE=$CIUX_IMAGE_URL" >> "$GITHUB_OUTPUT" | |
| echo "PROMOTED_IMAGE=$CIUX_PROMOTED_IMAGE_URL" >> "$GITHUB_OUTPUT" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-artifact | |
| path: artifacts | |
| image-analysis: | |
| name: Analyze image | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| security-events: write | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Download image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-artifact | |
| path: artifacts | |
| - name: Load image in local registry | |
| run: | | |
| if [ -f artifacts/image.tar ]; then | |
| echo "Loading image ${{ needs.build.outputs.image }} from archive" | |
| docker load --input artifacts/image.tar | |
| else | |
| echo "Using existing image ${{ needs.build.outputs.image }}" | |
| fi | |
| - name: Scan fink-alert-simulator image | |
| uses: anchore/scan-action@v3 | |
| id: scan | |
| with: | |
| image: "${{ needs.build.outputs.image }}" | |
| fail-build: false | |
| - name: Display SARIF report | |
| run: | | |
| cat ${{ steps.scan.outputs.sarif }} | |
| - name: upload Anchore scan SARIF report | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: ${{ steps.scan.outputs.sarif }} | |
| push: | |
| name: Push image to registry | |
| runs-on: ubuntu-22.04 | |
| needs: build | |
| steps: | |
| - name: Download image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-artifact | |
| path: artifacts | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: gitlab-registry.in2p3.fr | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_TOKEN }} | |
| - name: Push image to container registry | |
| run: | | |
| IMAGE="${{ needs.build.outputs.image }}" | |
| PROMOTED_IMAGE="${{ needs.build.outputs.promoted_image }}" | |
| if [ -f artifacts/image.tar ]; then | |
| echo "Loading image $IMAGE from archive" | |
| docker load --input artifacts/image.tar | |
| docker push $IMAGE | |
| else | |
| echo "Image exist in registry: $IMAGE" | |
| if which skopeo; then | |
| echo "skopeo is already installed" | |
| else | |
| echo "Install skopeo" | |
| sudo apt-get update -y | |
| sudo apt-get install -y skopeo | |
| fi | |
| echo "Rename image $IMAGE to $PROMOTED_IMAGE" | |
| skopeo copy docker://$IMAGE docker://$PROMOTED_IMAGE | |
| fi | |