Merge pull request #13 from betadots/puppet8 #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build container 🐳 | |
on: | |
push: | |
paths-ignore: | |
- '.github/**' | |
branches: | |
- 'main' | |
tags: | |
- '*' | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get tags | |
shell: python | |
run: | | |
import re | |
import os | |
from packaging.version import parse | |
image = "ghcr.io/${{ github.repository }}" | |
tags = set() | |
version = "${{ github.ref_name }}" | |
if version.startswith('v'): | |
version = "${{ github.ref_name }}".replace("v", "") | |
tags.add(f"{image}:latest") | |
if version == 'main': | |
version = "development" | |
tags.add(f"{image}:{version}") | |
tags = ",".join(sorted(list(tags))) | |
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: | |
print(f'tags={tags}', file=fh) | |
id: tags | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.tags.outputs.tags }} |