Skip to content

Merge pull request #11 from bossm8/dependabot/go_modules/github.com/s… #33

Merge pull request #11 from bossm8/dependabot/go_modules/github.com/s…

Merge pull request #11 from bossm8/dependabot/go_modules/github.com/s… #33

name: Build Templater Docker Images
on:
push:
branches:
- '*'
- '*/*'
- '**'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GO_VERSION: '1.20'
jobs:
build-dockerfiles:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up GO
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Generate Dockerfiles
run: |
go run main.go \
--config dtpl.dev.yml
- name: Upload Generated Dockerfiles
uses: actions/upload-artifact@v3
with:
name: dockerfiles
path: dockerfiles
build-dockerimages:
runs-on: ubuntu-latest
needs: build-dockerfiles
strategy:
matrix:
dockerfile: [Dockerfile.templater.dev, Dockerfile.templater.dev-debug]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Download Generated Dockerfiles
uses: actions/download-artifact@v3
with:
name: dockerfiles
path: ${{ github.workspace }}/dockerfiles
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Image Tag
run: |
echo "IMAGE_TAG=$(echo ${{ matrix.dockerfile }} | cut -d '.' -f 3)" >> $GITHUB_ENV
ls -la ${{ github.workspace }}/dockerfiles
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
context: ${{ github.workspace }}
file: ${{ github.workspace }}/dockerfiles/${{ matrix.dockerfile }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
test-dockerimages:
runs-on: ubuntu-latest
needs: build-dockerimages
strategy:
matrix:
tags: [dev, dev-debug]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test
run: |
docker run --rm \
-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tags }} \
--config dtpl.dev.yml -v -y