diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c7d170..8e85703 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,4 @@ +--- version: 2 updates: # Maintain dependencies for GitHub Actions diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 0b7b9bf..03439b4 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,3 +1,4 @@ +--- name-template: '$RESOLVED_VERSION 🌈' tag-template: '$RESOLVED_VERSION' version-template: '$MAJOR.$MINOR' @@ -14,7 +15,7 @@ categories: - title: '🧰 Maintenance' label: 'chore' change-template: '- $TITLE @$AUTHOR (#$NUMBER)' -change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: major: labels: diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml index 2b7901f..bf04948 100644 --- a/.github/workflows/action_branch.yml +++ b/.github/workflows/action_branch.yml @@ -26,14 +26,14 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-build-multi-arch.yml@v0.1.0 + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master with: enabled: true can_deploy: true name: ${{ needs.params.outputs.name }} - version: ${{ needs.params.outputs.matrix_version }} - arch: ${{ needs.params.outputs.matrix_arch }} - refs: ${{ needs.params.outputs.matrix_refs }} + matrix_version: ${{ needs.params.outputs.matrix_version }} + matrix_arch: ${{ needs.params.outputs.matrix_arch }} + matrix_refs: ${{ needs.params.outputs.matrix_refs }} secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml index d6a7981..bbb622f 100644 --- a/.github/workflows/action_pull_request.yml +++ b/.github/workflows/action_pull_request.yml @@ -23,14 +23,14 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-build-multi-arch.yml@v0.1.0 + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master with: enabled: true can_deploy: false name: ${{ needs.params.outputs.name }} - version: ${{ needs.params.outputs.matrix_version }} - arch: ${{ needs.params.outputs.matrix_arch }} - refs: ${{ needs.params.outputs.matrix_refs }} + matrix_version: ${{ needs.params.outputs.matrix_version }} + matrix_arch: ${{ needs.params.outputs.matrix_arch }} + matrix_refs: ${{ needs.params.outputs.matrix_refs }} secrets: dockerhub_username: "" dockerhub_password: "" diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml index e164dbe..ed423c7 100644 --- a/.github/workflows/action_schedule.yml +++ b/.github/workflows/action_schedule.yml @@ -24,14 +24,14 @@ jobs: # (2/2) Build docker: needs: [params] - uses: devilbox/github-actions/.github/workflows/docker-build-multi-arch.yml@v0.1.0 + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master with: enabled: true can_deploy: true name: ${{ needs.params.outputs.name }} - version: ${{ needs.params.outputs.matrix_version }} - arch: ${{ needs.params.outputs.matrix_arch }} - refs: ${{ needs.params.outputs.matrix_refs }} + matrix_version: ${{ needs.params.outputs.matrix_version }} + matrix_arch: ${{ needs.params.outputs.matrix_arch }} + matrix_refs: ${{ needs.params.outputs.matrix_refs }} secrets: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 093fd44..d12ca04 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -6,6 +6,25 @@ name: params +# ------------------------------------------------------------------------------------------------- +# Custom Variables +# ------------------------------------------------------------------------------------------------- +env: + NAME: PHP + MATRIX_VERSION: >- + [ + { + "NAME": "PHP", + "VERSION": "5.2" + } + ] + MATRIX_ARCH: >- + [ + "linux/amd64", + "linux/386" + ] + + # ------------------------------------------------------------------------------------------------- # When to run # ------------------------------------------------------------------------------------------------- @@ -25,15 +44,6 @@ on: description: "The determined git ref matrix (only during scheduled run)" value: ${{ jobs.params.outputs.matrix_refs }} -### -### Generic configuration -### -env: - NAME: PHP - MATRIX_VERSION: '["5.2"]' - MATRIX_ARCH: '["linux/amd64","linux/386"]' - - jobs: params: runs-on: ubuntu-latest @@ -45,22 +55,28 @@ jobs: matrix_refs: ${{ steps.set-matrix-refs.outputs.matrix }} steps: + - name: Test JSON + run: | + jq -M -c \ + --argjson arches '${{ env.MATRIX_ARCH }}' \ + 'map({NAME:.NAME, VERSION, ARCH:$arches[]})' <<<'${{ env.MATRIX_VERSION }}' + - name: "Set Name" id: set-name run: | echo '::set-output name=name::${{ env.NAME }}' - - name: "Set Matrix 'Version'" + - name: "[Set-Output] Matrix 'Version'" id: set-matrix-version run: | - echo '::set-output name=matrix::${{ env.MATRIX_VERSION }}' + echo "::set-output name=matrix::$( echo '${{ env.MATRIX_VERSION }}' | jq -M -c )" - - name: "Set Matrix 'Arch'" + - name: "[Set-Output] Matrix 'Arch'" id: set-matrix-arch run: | - echo '::set-output name=matrix::${{ env.MATRIX_ARCH }}' + echo "::set-output name=matrix::$( echo '${{ env.MATRIX_ARCH }}' | jq -M -c )" - - name: "Set Matrix 'Refs' (master branch and latest tag)" + - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" id: set-matrix-refs uses: cytopia/git-ref-matrix-action@v0.1.2 with: @@ -69,24 +85,24 @@ jobs: num_latest_tags: 1 if: github.event_name == 'schedule' - - name: "Show settings'" + - name: "[DEBUG] Show settings'" run: | echo 'Name' echo '--------------------' - echo ${{ steps.set-name.outputs.name }} + echo '${{ steps.set-name.outputs.name }}' echo echo 'Matrix: Version' echo '--------------------' - echo ${{ steps.set-matrix-version.outputs.matrix }} + echo '${{ steps.set-matrix-version.outputs.matrix }}' echo echo 'Matrix: Arch' echo '--------------------' - echo ${{ steps.set-matrix-arch.outputs.matrix }} + echo '${{ steps.set-matrix-arch.outputs.matrix }}' echo echo 'Matrix: Refs' echo '--------------------' - echo ${{ steps.set-matrix-refs.outputs.matrix }} + echo '${{ steps.set-matrix-refs.outputs.matrix }}' echo diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 4ff66c1..1a63d7e 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,3 +1,4 @@ +--- name: Release Drafter on: diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7457dff --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Makefile.docker +Makefile.lint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..2c7758f --- /dev/null +++ b/.yamllint @@ -0,0 +1,13 @@ +--- +extends: default + +ignore: | + .yamllint + + +rules: + truthy: + allowed-values: ['true', 'false'] + check-keys: False + level: error + line-length: disable diff --git a/Makefile b/Makefile index 6ed0101..9dc5459 100644 --- a/Makefile +++ b/Makefile @@ -2,78 +2,73 @@ ifneq (,) .error This Makefile requires GNU Make. endif +# Ensure additional Makefiles are present +MAKEFILES = Makefile.docker Makefile.lint +$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) +$(MAKEFILES): + @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ + echo "Error, curl or wget required."; \ + echo "Exiting."; \ + false; \ + fi +include $(MAKEFILES) + +# Set default Target +.DEFAULT_GOAL := help + # ------------------------------------------------------------------------------------------------- -# Docker configuration +# Default configuration # ------------------------------------------------------------------------------------------------- +NAME = PHP +VERSION = 5.2 +IMAGE = devilbox/php-fpm-5.2 +DIR = . +FILE = Dockerfile +TAG = latest +ARCH = linux/amd64 -DIR = . -FILE = Dockerfile -IMAGE = devilbox/php-fpm-5.2 -TAG = latest -ARCH = linux/amd64 -NO_CACHE = - +FL_IGNORES = .git/,.github/,tests/,data/ # ------------------------------------------------------------------------------------------------- # Default Target # ------------------------------------------------------------------------------------------------- .PHONY: help help: - @echo "lint Lint project files and repository" + @echo "lint Lint project files and repository" @echo - @echo "build Build Docker image" - @echo "rebuild Build Docker image without cache" + @echo "build [ARCH=...] [TAG=...] Build Docker image" + @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" + @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" @echo - @echo "manifest-create Create multi-arch manifest" - @echo "manifest-push Push multi-arch manifest" + @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" + @echo "manifest-push [TAG=...] Push multi-arch manifest" @echo - @echo "test Test built Docker image" - @echo "update-readme Update README.md with PHP modules" + @echo "test [ARCH=...] Test built Docker image" @echo - @echo "tag [TAG=...] Retag Docker image" - @echo "login USER=... PASS=... Login to Docker hub" - @echo "push [TAG=...] Push Docker image to Docker hub" # ------------------------------------------------------------------------------------------------- -# Lint Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: lint - @echo "No linting defined." - - -# ------------------------------------------------------------------------------------------------- -# Build Targets +# Docker Targets # ------------------------------------------------------------------------------------------------- .PHONY: build -build: - docker build --platform $(ARCH) $(NO_CACHE) -t $(IMAGE):$(TAG) -f $(DIR)/$(FILE) $(DIR) +build: docker-arch-build .PHONY: rebuild -rebuild: NO_CACHE=--no-cache -rebuild: pull-base-image -rebuild: build +rebuild: docker-arch-rebuild + +.PHONY: push +push: docker-arch-push # ------------------------------------------------------------------------------------------------- # Manifest Targets # ------------------------------------------------------------------------------------------------- .PHONY: manifest-create -manifest-create: - @echo "docker manifest create \ - $(IMAGE):$(TAG) \ - $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ - | sed 's/\s\s*/ /g' \ - | sed 's/--/\\\n --/g' - @echo "docker manifest create \ - $(IMAGE):$(TAG) \ - $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ - | bash +manifest-create: docker-manifest-create .PHONY: manifest-push -manifest-push: - docker manifest push $(IMAGE):$(TAG) +manifest-push: docker-manifest-push # ------------------------------------------------------------------------------------------------- @@ -93,37 +88,3 @@ update-readme: | perl -0 -pe "s/.*/\n$$(./tests/get-modules.sh $(IMAGE) $(ARCH))\n/s" \ > "./README.md.tmp" yes | mv -f "./README.md.tmp" "./README.md" - - -# ------------------------------------------------------------------------------------------------- -# Deploy Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: tag -tag: - docker tag $(IMAGE) $(IMAGE):$(TAG) - -.PHONY: login -login: - yes | docker login --username $(USER) --password $(PASS) - -.PHONY: push -push: - @$(MAKE) tag TAG=$(TAG) - docker push $(IMAGE):$(TAG) - -.PHONY: push-arch -push-arch: - $(MAKE) tag TAG=$(TAG)-manifest-$(subst /,-,$(ARCH)) - docker push $(IMAGE):$(TAG)-manifest-$(subst /,-,$(ARCH)) - - -# ------------------------------------------------------------------------------------------------- -# Helper Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: enter -enter: - docker run --rm --platform=$(ARCH) -it --entrypoint=bash $(ARG) $(IMAGE) - -.PHONY: pull-base-image -pull-base-image: - @docker pull --platform $(ARCH) $(shell grep FROM Dockerfile | sed 's/^FROM\s*//g';)