added new make commands (#18) #12
This file contains 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
# the works flow will build the code and only | |
# deploy/push the new container to a container | |
# repository when it on the brach cloudzero_optimized | |
# | |
# Since CloudZero has changes in the fork that will never be | |
# push back to AWS, we will manage our changes on | |
# branch cloudzero_optimized | |
name: cloudzero-optimized Multi-arch Builds | |
# Controls when the workflow will run | |
on: | |
push: | |
branches: | |
- cloudzero-optimized | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: write | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
multi-arch-build: | |
runs-on: ubuntu-latest | |
steps: | |
# Get the repositery's code | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# the version of the container is the latest git tag. | |
# This pull in the git tags | |
- name: get fetch to update tags locally | |
run: git fetch --prune --unshallow --tags | |
- name: last tag | |
run: | | |
if ${{ github.ref == 'refs/heads/cloudzero-optimized' }}; then | |
LAST_TAG=$(git describe HEAD --tags | grep -Eo "^v[0-9]+(\.[0-9]+)*") | |
else | |
LAST_TAG=$(git describe HEAD --tags) | |
fi | |
echo "LAST_TAG=${LAST_TAG}" | |
echo "LAST_TAG=${LAST_TAG}" >> $GITHUB_ENV | |
- name: set up semver | |
uses: madhead/semver-utils@latest | |
id: version | |
with: | |
# A version to work with | |
version: ${{ env.LAST_TAG }} | |
- name: Get NEXT_TAG value | |
run: | | |
if ${{ github.ref == 'refs/heads/cloudzero-optimized' }}; then | |
NEXT_TAG=${{ steps.version.outputs.inc-patch }} | |
else | |
NEXT_TAG=${{ env.LAST_TAG }} | |
fi | |
echo "NEXT_TAG=${NEXT_TAG}" | |
echo "NEXT_TAG=${NEXT_TAG}" >> $GITHUB_ENV | |
- name: add version for build | |
run: | | |
mkdir -p build/bin | |
echo '${{ env.NEXT_TAG }}' > build/bin/CEAGENT_VERSION | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: v0.9.1 | |
- name: repository owner | |
run: echo '${{ github.repository_owner }}' | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta_cloudzero_agent | |
uses: docker/metadata-action@v3 | |
with: | |
images: | | |
ghcr.io/cloudzero/cloudzero-agent | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=${{env.NEXT_TAG}} | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'cloudzero_optimized') }} | |
labels: | | |
app.kubernetes.io/name=cloudzero-agent | |
app.kubernetes.io/version=v${{env.NEXT_TAG}} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
env: | |
BUILDX_NO_DEFAULT_ATTESTATION: 1 | |
with: | |
context: . | |
file: amazon-cloudwatch-container-insights/cloudwatch-agent-dockerfile/source/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/cloudzero-optimized' }} | |
tags: ${{ steps.meta_cloudzero_agent.outputs.tags }} | |
provenance: false | |
buildkitd-flags: --debug | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Image digest | |
run: echo '${{ steps.docker_build.outputs.digest }}' | |
- name: Release | |
if: ${{ github.ref == 'refs/heads/cloudzero-optimized' }} | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
name: V${{ env.NEXT_TAG }} | |
tag_name: v${{ env.NEXT_TAG }} | |
target_commitish: cloudzero-optimized | |