Merge pull request #108 from ARPA-Network/node-client-enhancement #43
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
name: Build and Publish Docker | |
on: | |
push: | |
branches: | |
- main | |
# Trigger without any parameters a proactive rebuild | |
workflow_dispatch: {} | |
workflow_call: | |
env: | |
REGISTRY: ghcr.io | |
NODE_CLIENT_IMAGE_NAME: node-client | |
NODE_CONFIG_CHECKER_IMAGE_NAME: node-config-checker | |
NODE_SHELL_IMAGE_NAME: node-shell | |
USER_SHELL_IMAGE_NAME: user-shell | |
jobs: | |
node-client: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
timeout-minutes: 120 | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
install: true | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: "${{ github.repository_owner }}" | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
# Ensure this doesn't trigger on PR's | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CLIENT_IMAGE_NAME }} | |
# Creates an additional nightly-{SHA} tag | |
- name: Finalize Docker Metadata | |
id: docker_tagging | |
run: | | |
echo "trigger from main branch, assigning latest tag" | |
echo "docker_tags=${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CLIENT_IMAGE_NAME }}:nightly-${GITHUB_SHA},${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CLIENT_IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT | |
# Log docker metadata to explicitly know what is being pushed | |
- name: Inspect Docker Metadata | |
run: | | |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" | |
echo "LABELS -> ${{ steps.meta.outputs.labels }}" | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./docker/node-client/Dockerfile | |
push: true | |
tags: ${{ steps.docker_tagging.outputs.docker_tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
secrets: | | |
"cloudwatch_upload_token=${{ secrets.CLOUDWATCH_UPLOAD_TOKEN }}" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
node-config-checker: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
timeout-minutes: 120 | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
install: true | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: "${{ github.repository_owner }}" | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
# Ensure this doesn't trigger on PR's | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CONFIG_CHECKER_IMAGE_NAME }} | |
# Creates an additional nightly-{SHA} tag | |
- name: Finalize Docker Metadata | |
id: docker_tagging | |
run: | | |
echo "trigger from main branch, assigning latest tag" | |
echo "docker_tags=${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CONFIG_CHECKER_IMAGE_NAME }}:nightly-${GITHUB_SHA},${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_CONFIG_CHECKER_IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT | |
# Log docker metadata to explicitly know what is being pushed | |
- name: Inspect Docker Metadata | |
run: | | |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" | |
echo "LABELS -> ${{ steps.meta.outputs.labels }}" | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./docker/node-config-checker/Dockerfile | |
push: true | |
tags: ${{ steps.docker_tagging.outputs.docker_tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
node-shell: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
timeout-minutes: 120 | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
install: true | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: "${{ github.repository_owner }}" | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
# Ensure this doesn't trigger on PR's | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_SHELL_IMAGE_NAME }} | |
# Creates an additional nightly-{SHA} tag | |
- name: Finalize Docker Metadata | |
id: docker_tagging | |
run: | | |
echo "trigger from main branch, assigning latest tag" | |
echo "docker_tags=${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_SHELL_IMAGE_NAME }}:nightly-${GITHUB_SHA},${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.NODE_SHELL_IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT | |
# Log docker metadata to explicitly know what is being pushed | |
- name: Inspect Docker Metadata | |
run: | | |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" | |
echo "LABELS -> ${{ steps.meta.outputs.labels }}" | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./docker/node-shell/Dockerfile | |
push: true | |
tags: ${{ steps.docker_tagging.outputs.docker_tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
user-shell: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
timeout-minutes: 120 | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
install: true | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: "${{ github.repository_owner }}" | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
# Ensure this doesn't trigger on PR's | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.USER_SHELL_IMAGE_NAME }} | |
# Creates an additional nightly-{SHA} tag | |
- name: Finalize Docker Metadata | |
id: docker_tagging | |
run: | | |
echo "trigger from main branch, assigning latest tag" | |
echo "docker_tags=${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.USER_SHELL_IMAGE_NAME }}:nightly-${GITHUB_SHA},${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ env.USER_SHELL_IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT | |
# Log docker metadata to explicitly know what is being pushed | |
- name: Inspect Docker Metadata | |
run: | | |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" | |
echo "LABELS -> ${{ steps.meta.outputs.labels }}" | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./docker/user-shell/Dockerfile | |
push: true | |
tags: ${{ steps.docker_tagging.outputs.docker_tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} |