Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
chore(template): sync with ahmadnassri/template-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Aug 4, 2022
1 parent 5aba187 commit fe81893
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 51 deletions.
6 changes: 6 additions & 0 deletions .github/publish-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"include": [
{ "id": "GH", "registry": "ghcr.io" },
{ "id": "DOCKER", "registry": "docker.io" }
]
}
90 changes: 49 additions & 41 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@ jobs:
runs-on: ubuntu-latest

outputs:
image-name: ${{ steps.image.outputs.name }}
repository: ${{ steps.metadata.outputs.repository }}

steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3

- uses: ahmadnassri/action-metadata@v1
id: metadata

- id: image
run: echo "::set-output name=name::$(basename "${GITHUB_REPOSITORY/docker-//}")"

commit-lint:
timeout-minutes: 5

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3

- uses: ahmadnassri/action-commit-lint@v1
with:
Expand All @@ -39,17 +43,31 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: github/super-linter/slim@v4
env:
LOG_LEVEL: ERROR
IGNORE_GITIGNORED_FILES: true
VALIDATE_ALL_CODEBASE: false
FILTER_REGEX_EXCLUDE: '/github/workspace/README.md|test/fixtures/*'
GITHUB_TOKEN: ${{ github.token }}

publish-strategy:
timeout-minutes: 5

runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.parse.outputs.matrix }}

steps:
- uses: actions/checkout@v3
- id: parse
run: echo "::set-output name=matrix::$(jq -c . < .github/publish-matrix.json)"

release:
timeout-minutes: 5

Expand All @@ -69,69 +87,59 @@ jobs:
release-version-minor: ${{ steps.release.outputs.release-version-minor }}

steps:
- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3
- id: release
uses: ahmadnassri/action-semantic-release@v1
uses: ahmadnassri/action-semantic-release@v2
with:
config: ${{ github.workspace }}/.semantic.json
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

publish:
timeout-minutes: 10

needs:
- release
- metadata
- publish-strategy

timeout-minutes: 10

if: ${{ needs.release.outputs.published == 'true' }}

runs-on: ubuntu-latest
name: ${{ format('publish to {0}', matrix.registry) || 'publish-step' }}

steps:
- uses: actions/checkout@v2.3.5
- uses: actions/cache@v2.1.7
with:
path: /tmp/.buildx-cache
key: buildx-${{ github.sha }}
restore-keys: buildx-
strategy:
matrix: ${{ fromJSON(needs.publish-strategy.outputs.matrix) }}

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
runs-on: ubuntu-latest

# login to docker hub
- uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

# login to github container registry
- uses: docker/login-action@v1
# login to registry
- uses: docker/login-action@v2
with:
registry: ghcr.io
registry: ${{ matrix.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}

- id: hub
run: echo "::set-output name=name::$(basename "${GITHUB_REPOSITORY/docker-//}")"
password: ${{ secrets[format('{0}_TOKEN', matrix.id)] }}

# publish
- uses: docker/build-push-action@v2
- uses: docker/build-push-action@v3
with:
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:latest
${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ needs.release.outputs.release-version-major }}
${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ needs.release.outputs.release-version }}
ghcr.io/${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ needs.release.outputs.release-version-major }}
ghcr.io/${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ needs.release.outputs.release-version }}
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:latest
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.release-version-major }}
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.release-version }}
labels: |
org.opencontainers.image.title=${{ steps.hub.outputs.name }}
org.opencontainers.image.title=${{ needs.metadata.outputs.image-name }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ needs.release.outputs.release-version }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
template-sync:
Expand All @@ -151,7 +159,7 @@ jobs:
steps:
- uses: ahmadnassri/action-workflow-queue@v1.1

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v3

- uses: ahmadnassri/action-template-repository-sync@v1.6.0
with:
Expand Down
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/make

# ----------------------------------------------------------- #
# Note: this file is automatically managed in template-docker #
# ----------------------------------------------------------- #

# SHELL := /bin/bash

LINT_PATH := ${PWD}/${LINT_PATH}

# Docker

pull: ## pull latest containers
@docker compose pull

lint: clean ## run super-linter
@docker compose run --rm lint

readme: clean ## run readme action
@docker compose run --rm readme

start: ## start the project in foreground
@docker compose up --renew-anon-volumes app

build: clean ## start the project in background
@docker compose build app

shell: ## start the container shell
@docker compose run --rm --entrypoint /bin/sh app

stop: ## stop all running containers
@docker compose down --remove-orphans --rmi local

clean: stop ## remove running containers, volumes, node_modules & anything else
@docker compose rm --stop --volumes --force

# Utility methods
## Help: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html

help: ## display this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help
.PHONY: help
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ services:
LOG_LEVEL: 'ERROR'
RUN_LOCAL: 'true'
MULTI_STATUS: 'false'
IGNORE_GITIGNORED_FILES: 'true'
FILTER_REGEX_EXCLUDE: '/tmp/lint/README.md|test/fixtures/*'

# ---- readme generator ---- #
readme:
image: pandoc/core:2.11.4
image: pandoc/minimal:2.18.0
volumes:
- ./:/data
command: >-
Expand All @@ -26,3 +28,10 @@ services:
--wrap=preserve
--reference-links
docs/README.md
# ---- app ---- #
app:
privileged: true
build: .
env_file:
- .env
9 changes: 0 additions & 9 deletions docs/README.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ $about.description$

[![license][license-img]][license-url]
[![release][release-img]][release-url]
[![super linter][super-linter-img]][super-linter-url]
[![semantic][semantic-img]][semantic-url]

[![size][size-img]][size-url]
[![docker][docker-img]][docker-url]
[![github][github-img]][github-url]
Expand All @@ -23,12 +20,6 @@ $body$
[release-url]: https://github.com/$about.repository$/releases
[release-img]: https://badgen.net/github/release/$about.repository$

[super-linter-url]: https://github.com/$about.repository$/actions?query=workflow%3Asuper-linter
[super-linter-img]: https://github.com/$about.repository$/workflows/super-linter/badge.svg

[semantic-url]: https://github.com/$about.repository$/actions?query=workflow%3Arelease
[semantic-img]: https://badgen.net/badge/📦/semantically%20released/blue

[size-url]: https://hub.docker.com/r/ahmadnassri/$id$
[size-img]: https://badgen.net/docker/size/ahmadnassri/$id$

Expand Down

0 comments on commit fe81893

Please sign in to comment.