Skip to content

busma13 has triggered a build and push of the Terascope Base Image #125

busma13 has triggered a build and push of the Terascope Base Image

busma13 has triggered a build and push of the Terascope Base Image #125

Workflow file for this run

name: release
run-name: ${{ github.actor }} has triggered a build and push of the Terascope Base Image
on:
release:
types: [published]
schedule:
- cron: '30 5 * * 0' # Sunday's at 0530
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/node-base
jobs:
compute-versions-from-env:
runs-on: ubuntu-latest
outputs:
TERAFOUNDATION_KAFKA_CONNECTOR_VERSION: ${{ steps.dotenv.outputs.TERAFOUNDATION_KAFKA_CONNECTOR_VERSION }}
IMAGE_VERSION: ${{ steps.dotenv.outputs.IMAGE_VERSION }}
NODE_VERSIONS_ARRAY: ${{ steps.dotenv.outputs.NODE_VERSIONS_ARRAY }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get versions from .env file using Dotenv Action
id: dotenv
uses: falti/dotenv-action@v1.1.4
with:
log-variables: true
keys-case: bypass
build_and_release_matrix:
needs: 'compute-versions-from-env'
strategy:
matrix:
# NOTE: The NODE_VERSION_ARRAY is stored in the .env file.
# In the case where a new node version introduces a breaking change,
# replace the major version of the matrix to a pinned version.
# Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"]
version: ${{ fromJSON(needs.compute-versions-from-env.outputs.NODE_VERSIONS_ARRAY) }}
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64,linux/amd64
-
name: Get timestamp for docker build
id: docker_time_stamp
run: echo "BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")" >> $GITHUB_ENV
-
name: Build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64,linux/amd64
build-args: |
"NODE_VERSION=${{ matrix.version }}"
"GITHUB_SHA=${{ github.sha }}"
"BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}"
"TERAFOUNDATION_KAFKA_CONNECTOR_VERSION=${{ needs.compute-versions-from-env.outputs.TERAFOUNDATION_KAFKA_CONNECTOR_VERSION }}"
"IMAGE_VERSION=${{ needs.compute-versions-from-env.outputs.IMAGE_VERSION }}"
provenance: false
sbom: true
pull: true
push: true
file: ./Dockerfile
tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}"
-
name: Grab Current Version
id: current_version
run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }} node -v)" >> $GITHUB_ENV
-
name: Grab Minor Version
id: minor_version
run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV
-
name: Grab Patch Version
id: patch_version
run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV
-
name: Check for specific node version
id: check_specific_version
run: |
if [[ "${{ matrix.version }}" == *.* ]]; then
echo "SPECIFIC_VERSION=true" >> $GITHUB_ENV
else
echo "SPECIFIC_VERSION=false" >> $GITHUB_ENV
fi
-
name: Grab Major Version
if: ${{ env.SPECIFIC_VERSION == 'true' }}
id: major_version
run: echo "MAJOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} major)" >> $GITHUB_ENV
-
name: Retag, and push minor/patch images
if: ${{ env.SPECIFIC_VERSION == 'false' }}
run: |
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }}
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} ${{ env.IMAGE_NAME }}:${{ matrix.version }}
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}
-
name: Retag, and push major/minor images
if: ${{ env.SPECIFIC_VERSION == 'true' }}
run: |
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }}
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }}
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}
slack-announcement:
# Only announce release when a release is published
if: github.event_name == 'release' && github.event.action == 'published'
needs: [build_and_release_matrix, compute-versions-from-env]
runs-on: ubuntu-latest
steps:
-
name: Announce release in Slack releases channel
id: announce-release
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ vars.SLACK_RELEASES_CHANNEL_ID }}
text: |
base-docker-image version `v${{ needs.compute-versions-from-env.outputs.IMAGE_VERSION }}` has been released.
Please review and revise the automated release notes:
https://github.com/terascope/base-docker-image/releases/tag/v${{ needs.compute-versions-from-env.outputs.IMAGE_VERSION }}
Docker images: https://github.com/terascope/base-docker-image/pkgs/container/node-base
-
name: Failed Announcement Response
if: ${{ steps.announce-release.outputs.ok == 'false' }}
run: echo "Slackbot API failure response - ${{ steps.announce-release.outputs.response }}"
trigger-teraslice-docker-cache-workflow:
needs: [build_and_release_matrix, compute-versions-from-env]
runs-on: ubuntu-latest
steps:
-
name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.GH_CROSS_REPO_ACTIONS_APP_ID }}
private-key: ${{ secrets.GH_CROSS_REPO_ACTIONS_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: teraslice
-
name: Send workflow dispatch event to teraslice
run: |
curl -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
https://api.github.com/repos/terascope/teraslice/actions/workflows/daily-docker-cache.yml/dispatches \
-d '{"ref":"master","inputs":{"reason":"New Base Images Released"}}'
# I don't think we use the core images and we should consider removing this and the Dockerfile.core file.
# -
# name: Build Core
# uses: docker/build-push-action@v6
# with:
# context: .
# platforms: linux/arm64,linux/amd64
# build-args: "NODE_VERSION=${{ matrix.version }}"
# pull: true
# push: true
# file: ./Dockerfile.core
# tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core"
# Look into this more:
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.build_and_release_matrix.outputs.digest }}
# push-to-registry: true