Skip to content

chore: add avm-res-deviceregistry-assetendpointprofiles metadata #25

chore: add avm-res-deviceregistry-assetendpointprofiles metadata

chore: add avm-res-deviceregistry-assetendpointprofiles metadata #25

---
name: container - release
# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
tags:
- 'v*.*.*' # Matches semantic version tags like v1.0.0, v2.3.4, etc.
# Configures this workflow to run when the workflow is manually triggered from the GitHub UI.
pull_request:
branches:
- main
workflow_dispatch:
# 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:
PLATFORMS: linux/amd64,linux/arm64
TAG_PREFIX: avm-
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
environment: acr
strategy:
fail-fast: false
matrix:
image:
- name: azterraform
repo: public/azterraform
tag_prefix: ""
dockerfile: Dockerfile
source_files: "Dockerfile.build Dockerfile.azterraform"
- name: avm
repo: public/azterraform
tag_prefix: "avm-"
dockerfile: Dockerfile
source_files: "Dockerfile.build Dockerfile.avm"
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# Uses the `docker/login-action` action to log in to the Container registry 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@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ${{ secrets.ACR_SERVER_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_TOKEN }}
- uses: juliangruber/read-file-action@02bbba9876a8f870efd4ad64e3b9088d3fb94d4b # v1.1.6
id: readenv
with:
path: ./container/version.env
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
images: |
${{ secrets.ACR_SERVER_URL }}/${{ matrix.image.repo }}
flavor: |
latest=auto
prefix=${{ matrix.image.tag_prefix }},onlatest=true
tags: |
type=semver,pattern={{version}},prefix=${{ matrix.image.tag_prefix }}v
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.image.tag_prefix }}v
type=semver,pattern={{major}},prefix=${{ matrix.image.tag_prefix }}v
type=sha,prefix=${{ matrix.image.tag_prefix }}sha-,format=long
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Concat Dockerfiles
run: |
cat ${{ matrix.image.source_files }} > ${{ matrix.image.dockerfile }}
rm -f Dockerfile.* || true
working-directory: ./container
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: ${{ env.PLATFORMS }}
cache-image: true
- name: Set up Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
version: latest
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push image
id: push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: ./container
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
${{ steps.readenv.outputs.content }}
platforms: ${{ env.PLATFORMS }}
cache-from: type=registry,ref=${{ secrets.ACR_SERVER_URL }}/${{ matrix.image.repo }}:${{ matrix.image.tag_prefix }}latest
cache-to: type=inline
# 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 [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
- name: Generate artifact attestation
if: startsWith(github.ref, 'refs/tags/')
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
with:
subject-name: ${{ secrets.ACR_SERVER_URL }}/${{ matrix.image.repo }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true