Skip to content

fix: dependsOn bug fix for node rest use cases #27

fix: dependsOn bug fix for node rest use cases

fix: dependsOn bug fix for node rest use cases #27

#
# LICENSE START
#
# Copyright (c) NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# LICENSE END
#
name: Build and push agentless container image
# Configures this workflow to run every time a tag is created
on:
pull_request:
branches:
- main
paths:
- containers/agentless/**
- .github/workflows/agentless-container.yaml
push:
branches:
- main
paths:
- containers/agentless/**
- .github/workflows/agentless-container.yaml
# NOTE: we may want to switch to matrix build for multi-platform support if this is taking too long
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKER_CMD: docker
jobs:
build-and-publish-agentless:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup for multi-platform
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the agent container image
id: build
run: |
source ./containers/agentless/versions.sh
cd agent
export TAGS=()
for version in $TEST_VERSIONS; do
TAGS+="-t ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agentless:$version "
done
TAGS=$(echo $TAGS | tr '[:upper:]' '[:lower:]')
echo "======== Tags: ========\n $TAGS"
# GITHUB_BASE_REF is only set when the action source event is a pull request.
# in that case don't push.
export PUSH=$(if [ ${{ github.event_name }} != 'pull_request' ]; then echo "--push"; else echo ""; fi)
docker buildx build $PUSH --platform linux/amd64,linux/arm64 $TAGS --metadata-file=metadata.json -f ../containers/agentless/Dockerfile ../containers/agentless
cat metadata.json
echo "digest=$(cat metadata.json | jq -r .\"containerimage.digest\")" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
if: ${{ github.event_name != 'pull_request' }}
with:
subject-name: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agentless
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true