Skip to content

butler-sos: v11.0.0 #30

butler-sos: v11.0.0

butler-sos: v11.0.0 #30

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# Inspiration
# https://github.com/actions/starter-workflows/blob/main/ci/docker-publish.yml
name: Docker image
on:
workflow_dispatch:
inputs:
tags:
description: 'Test scenario tags'
required: false
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
steps:
# - name: Send job status to MQTT (starting job)
# uses: potaesm/[email protected]
# if: always()
# env:
# JOB_CONCLUSION: ${{ job.status }}
# NODE_VERSION: ${{ matrix.node }}
# with:
# url: ${{ secrets.PUBLIC_MQTT_BROKER_URL }}
# topic: control/github_actions_action_runner
# payload: '{ "type":"ci-test", "repo": "${{ github.repository }}", "job": "${{ github.job }}", "workflow": "${{ github.workflow }}", "nodeVersion": "${{ env.NODE_VERSION }}","status": "in_progress","conclusion":"${{ env.JOB_CONCLUSION }}" }'
# username: ${{ secrets.PUBLIC_MQTT_BROKER_USER }}
# connectTimeout: 30000
- name: Show input values
run: |
echo "Inputs: ${{ github.event.inputs }}"
- name: Checkout repository
uses: actions/checkout@v4
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
# Login against a Docker registry except on PR
# https://github.com/marketplace/actions/docker-login
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
- name: Login to Docker Hub
uses: docker/login-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Docker tag has format: refs/tags/v1.2.3
# We need to extract the tag semver from the full tag
# Store the tag in GITHUB_ENV environment variable
- name: Create clean tag for Docker
run: |
#export TAGTMP1=${{ github.ref }}
#export TAG=${TAGTMP1##*/}
export TAG=$(echo ${{ github.ref }} | grep -oE "[0-9]+.[0-9]+.[0-9]+")
echo "TAG=$TAG" >> $GITHUB_ENV
#
# Debug
# echo "TAGTMP1=$TAGTMP1"
echo "TAG=$TAG"
echo "GITHUB_ENV=$GITHUB_ENV"
# export TAGTMP2=${TAGTMP1##*/}
# export TAG=${TAGTMP2##*-}
# echo "TAG=$TAG" >> $GITHUB_ENV
- name: Dump GitHub context
if: always()
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
if: always()
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
if: always()
env:
STEPS_CONTEXT: ${{ toJSON(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
if: always()
env:
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
if: always()
env:
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
run: echo "$STRATEGY_CONTEXT"
# Extract metadata (tags, labels) for Docker
# https://github.com/marketplace/actions/docker-metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
# images: ${{ env.IMAGE_NAME }}
images: ${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ env.TAG }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.TAG }}
type=semver,pattern={{major}},value=${{ env.TAG }}
- name: Show Docker tags that will be used
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo '${{ steps.meta.outputs.tags }}'
- name: Show Docker labels that will be used
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo '${{ steps.meta.outputs.labels }}'
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
context: .
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo ${{ steps.docker_build.outputs.digest }}
# - name: Send job status to MQTT when done
# uses: potaesm/[email protected]
# if: always()
# env:
# JOB_STATUS: ${{ job.status }}
# with:
# url: ${{ secrets.PUBLIC_MQTT_BROKER_URL }}
# topic: control/github_actions_action_runner
# payload: '{ "type":"docker-build", "repo": "${{ github.repository }}", "job": "${{ github.job }}", "workflow": "${{ github.workflow }}","status": "completed","conclusion":"${{ env.JOB_STATUS }}" }'
# username: ${{ secrets.PUBLIC_MQTT_BROKER_USER }}
# connectTimeout: 30000