Skip to content

Commit

Permalink
Merge pull request #52 from mountaindude/master
Browse files Browse the repository at this point in the history
1.3.0 WIP
  • Loading branch information
mountaindude authored Mar 7, 2023
2 parents 1e161d8 + 379dc55 commit d993406
Show file tree
Hide file tree
Showing 15 changed files with 13,475 additions and 915 deletions.
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.dockerignore
.eslintrc.yml
.gitignore
.jshintrc
.prettierignore
.prettierrc
.prettierrc.yaml
.snyk
.DS_Store
.cache_ggshield

__tests__
jest.config.js
coverage
test
test/*

CHANGELOG.md
Dockerfile
docker-compose.yaml
docker-compose.yml
package-lock.json
README.md

config
config/*
log
logs
14 changes: 14 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
env:
es6: true
es2021: true
node: true
extends:
- airbnb-base
- prettier
parserOptions:
ecmaVersion: 12
sourceType: module
rules:
prettier/prettier: error
plugins:
- prettier
178 changes: 178 additions & 0 deletions .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# 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: Build Docker image CI

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

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@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
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@v2
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create clean tag for Docker
run: |
export TAGTMP1=${{ github.ref }}
echo "TAG=$(echo "${TAGTMP1##*-}")" >> $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@v4
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@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
context: ./src
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 }}

# Send MQTT message similar to this:
# { "topic":"control/github_actions_action_runner",
# "payload":"{
# \"type\":\"docker-build\",
# \"repo\": \"ptarmiganlabs/butler\",
# \"job\": \"build\", \
# "workflow\": \"Build Docker image CI\",
# \"status\": \"completed\",
# \"conclusion\":\"success\"
# }"
# }
- 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
Loading

0 comments on commit d993406

Please sign in to comment.