Skip to content

Commit

Permalink
Continuous Integration and Docker publishing workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
bblacey committed Feb 5, 2021
1 parent 177297b commit c2f48c6
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

updates:
# NPM
- package-ecosystem: "npm" # See documentation for possible values
directory: "/node-app" # Location of package manifests
schedule:
interval: "daily"

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Continuous Integration

on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:

jobs:
build:
name: Build (Node ${{matrix.node}})

strategy:
matrix:
node: ['12', '15']
runs-on: ubuntu-20.04

steps:
- name: Github setup & checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Setup Node.js ${{matrix.node}}
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node}}

- name: CI Build & Install
run: |
cd node-app
npm install
npm run build --if-present
72 changes: 72 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Docker to ghcr.io

on:
release:
types: [created]

workflow_dispatch:

jobs:
test:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Run tests
run: docker-compose --file docker-compose.yml build

push:
needs: test

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Builder
id: buildx
uses: docker/setup-buildx-action@v1

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GCR_PAT }}

- name: Setup Environment
run: |
echo "IMAGE=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
echo "GITHUB_SHORT_SHA=${GITHUB_SHA:1:7}" >> $GITHUB_ENV
echo "GITHUB_REFNAME=${GITHUB_REF#refs/*/}" >> GITHUB_ENV
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Build image and push
uses: docker/build-push-action@v2
with:
context: node-app
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
labels: |
org.opencontainers.image.title=EZ-HouseMode-SceneRunner
org.opencontainers.image.authors=bruce@blacey.com
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.description=Created from commit ${{ env.GITHUB_SHORT_SHA }}, (ref ${{ env.GITHUB_REF_NAME }})
org.opencontainers.image.created=${{ env.BUILD_DATE }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.ref.name=${{ env.GITHUB_REFNAME }}
org.opencontainers.image.version=${{ env.VERSION }}
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ env.VERSION }}
push: true

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit c2f48c6

Please sign in to comment.