add docker build action

This commit is contained in:
Oliver Gorwits
2021-08-19 12:24:37 +01:00
parent d28bdaf3d5
commit 897095c9cb

73
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,73 @@
name: Netdisco Docker Images
on:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
# success_irc_squawk:
# description: 'Squawk to IRC on success'
# required: false
# default: false
push:
tags:
- '2.[0-9][0-9][0-9][0-9][0-9][0-9]'
jobs:
build_docker_images:
name: Build Docker Images
runs-on: ubuntu-latest
defaults:
run:
working-directory: /github/workspace/netdisco-docker/netdisco-docker
steps:
- name: Get the Tag
id: get_refs
run: |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "IMAGE_ROOT=netdisco:${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Check out latest code
uses: actions/checkout@v1
with:
repo: 'netdisco/netdisco-docker'
- name: Build netdisco-postgresql
id: build_netdisco_postgresql
run: |
cd netdisco-postgresql
docker build -t ${IMAGE_ROOT}-postgresql \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg TAG=${TAG} \
--build-arg COMMITTISH=${TAG} .
- name: Retag all images
run: |
for image in postgresql; do
docker tag ${IMAGE_ROOT}-$image netdisco/${IMAGE_ROOT}-$image
docker tag ${IMAGE_ROOT}-$image netdisco/netdisco:latest-$image
done
# - name: IRC upload failure notification
# uses: Gottox/irc-message-action@v2
# if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/')
# with:
# channel: '#netdisco'
# nickname: github-actions
# message: |-
# 🤖 Failed to upload Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN! 😭
# 👀 https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# - name: IRC upload success notification
# uses: Gottox/irc-message-action@v2
# if: (! github.event.inputs.debug_enabled) && startsWith(github.ref, 'refs/tags/')
# with:
# channel: '#netdisco'
# nickname: github-actions
# message: |-
# 🤖 Uploaded Netdisco release ${{ steps.get_refs.outputs.RELEASE_TAG }} to CPAN 🎉
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: always() && github.event.inputs.debug_enabled && (github.event_name == 'workflow_dispatch')
with:
sudo: true