diff --git a/.ansible-lint b/.ansible-lint
new file mode 100644
index 0000000..e2f880a
--- /dev/null
+++ b/.ansible-lint
@@ -0,0 +1,12 @@
+---
+
+# https://ansible-lint.readthedocs.io/en/latest/configuring/
+
+skip_list:
+ - experimental
+
+exclude_paths:
+ - ./contrib
+ - ./.venv
+
+...
diff --git a/.github/labeler.yml b/.github/labeler.yml
index 93afea4..3f6bf9f 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -1,3 +1,5 @@
+---
+
# this file is for the labeler workflow job
# Documentation https://github.com/marketplace/actions/labeler
@@ -10,3 +12,5 @@
- .dependabot/*
- .github/workflows/*
- src/**/goss.yaml.j2
+
+...
diff --git a/.github/workflows/label.yml b/.github/workflows/apply-labels.yml
similarity index 61%
rename from .github/workflows/label.yml
rename to .github/workflows/apply-labels.yml
index 1c654a3..c9b1196 100644
--- a/.github/workflows/label.yml
+++ b/.github/workflows/apply-labels.yml
@@ -1,8 +1,10 @@
+---
+
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
-# file with configuration. For more information, see:
+# file with configuration. For more information, see:
# https://github.com/actions/labeler/blob/master/README.md
on: # yamllint disable-line rule:truthy
@@ -12,11 +14,10 @@ name: ๐ท๏ธ Add labels
jobs:
label:
- runs-on: ubuntu-latest
- steps:
- - name: ๐ท๏ธ Apply labels
- uses: actions/labeler@v4
- with:
- repo-token: "${{ secrets.GITHUB_TOKEN }}"
+ uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master
+ with:
+ os: ubuntu-latest
+ secrets:
+ token: ${{ secrets.GITHUB_TOKEN }}
...
diff --git a/.github/workflows/auto-merge-release.yaml b/.github/workflows/auto-merge-release.yaml
index 9f4d53e..084a3e1 100644
--- a/.github/workflows/auto-merge-release.yaml
+++ b/.github/workflows/auto-merge-release.yaml
@@ -13,15 +13,14 @@ name: ๐ค Auto merge release
jobs:
auto-merge:
- if: github.actor == 'lotyp' && startsWith(github.head_ref, 'release-please--')
- runs-on: ubuntu-latest
- steps:
- - name: ๐ค Auto-merge pull request
- uses: peter-evans/enable-pull-request-automerge@v3
- with:
- pull-request-number: ${{ github.event.pull_request.number }}
- merge-method: merge
- # to trigger other workflows, pass PAT token instead of GITHUB_TOKEN
- token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
+ uses: wayofdev/gh-actions/.github/workflows/auto-merge-release.yml@master
+ with:
+ os: ubuntu-latest
+ pull-request-number: ${{ github.event.pull_request.number }}
+ actor: lotyp
+ merge-method: merge
+ secrets:
+ # to trigger other workflows, pass PAT token instead of GITHUB_TOKEN
+ token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
...
diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml
new file mode 100644
index 0000000..30ec3ac
--- /dev/null
+++ b/.github/workflows/build-latest.yml
@@ -0,0 +1,45 @@
+---
+
+on: # yamllint disable-line rule:truthy
+ workflow_dispatch:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+name: ๐ Build docker images with latest tag
+
+jobs:
+ # https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object
+ prepare:
+ runs-on: "ubuntu-latest"
+ outputs:
+ matrix: ${{ steps.matrix.outputs.matrix }}
+ steps:
+ - name: โ๏ธ Generate matrix
+ id: matrix
+ run: |
+ echo 'matrix={
+ "os_name": ["alpine"],
+ "node_version": ["lts", "18", "20"]
+ }' | tr -d '\n' >> $GITHUB_OUTPUT
+
+ build:
+ needs: prepare
+ strategy:
+ matrix: ${{ fromJson(needs.prepare.outputs.matrix )}}
+ uses: wayofdev/gh-actions/.github/workflows/build-image.yml@master
+ with:
+ os: "ubuntu-latest"
+ push-to-hub: true
+ image-namespace: "wayofdev/node"
+ image-template-path: "./dist"
+ image-template: ${{ matrix.node_version }}-${{ matrix.os_name }}
+ image-version: latest
+ secrets:
+ docker-username: ${{ secrets.DOCKER_USERNAME }}
+ docker-password: ${{ secrets.DOCKER_TOKEN }}
+
+...
diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
new file mode 100644
index 0000000..405e142
--- /dev/null
+++ b/.github/workflows/build-release.yml
@@ -0,0 +1,46 @@
+---
+
+on: # yamllint disable-line rule:truthy
+ release:
+ types:
+ - released
+
+name: ๐ Build docker images with release tag
+
+jobs:
+ # https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object
+ prepare:
+ runs-on: "ubuntu-latest"
+ outputs:
+ matrix: ${{ steps.matrix.outputs.matrix }}
+ steps:
+ - name: โ๏ธ Generate matrix
+ id: matrix
+ run: |
+ echo 'matrix={
+ "os_name": ["alpine"],
+ "node_version": ["lts", "18", "20"]
+ }' | tr -d '\n' >> $GITHUB_OUTPUT
+
+ - name: โ๏ธ Get version for image tag
+ id: version
+ run: |
+ echo "version=${{ github.ref_name#v }}" >> $GITHUB_OUTPUT
+
+ build:
+ needs: prepare
+ strategy:
+ matrix: ${{ fromJson(needs.prepare.outputs.matrix )}}
+ uses: wayofdev/gh-actions/.github/workflows/build-image.yml@master
+ with:
+ os: "ubuntu-latest"
+ push-to-hub: true
+ image-namespace: "wayofdev/node"
+ image-template-path: "./dist"
+ image-template: ${{ matrix.node_version }}-${{ matrix.os_name }}
+ image-version: ${{ needs.prepare.outputs.version }}
+ secrets:
+ docker-username: ${{ secrets.DOCKER_USERNAME }}
+ docker-password: ${{ secrets.DOCKER_TOKEN }}
+
+...
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 91fd779..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,120 +0,0 @@
----
-
-on: # yamllint disable-line rule:truthy
- push:
- branches:
- - 'master'
- tags:
- - 'v*.*.*'
- pull_request:
- branches:
- - 'master'
- release:
- types:
- - 'created'
- schedule:
- # Every Sunday at 01:10
- - cron: '10 1 * * 0'
-
-name: ๐ Continuous integration
-
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- node_version: [ 'lts', '19', '18' ]
- os_name: [ 'alpine' ]
- steps:
- - name: ๐ฆ Install goss
- uses: e1himself/goss-installation-action@v1.1.0
-
- - name: ๐ฆ Check out the codebase
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: ๐ Set environment variables
- env:
- IMAGE_NAMESPACE: wayofdev/node
- TEMPLATE: ${{ matrix.node_version }}-${{ matrix.os_name }}
- run: |
- export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
- && { \
- echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
- echo "TEMPLATE=${TEMPLATE}"; \
- echo "VERSION=${RELEASE_VERSION:1}"; \
- } >> "$GITHUB_ENV"
-
- - name: ๐ค Generate dist files
- run: make generate
-
- - name: ๐ณ Define docker meta
- id: meta
- uses: docker/metadata-action@v4
- with:
- images: ${{ env.IMAGE_NAMESPACE }}
- tags: |
- type=raw,event=branch,value=latest
- type=ref,event=pr
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- flavor: |
- latest=false
- prefix=${{ matrix.node_version }}-${{ matrix.os_name }}-
-
- - name: ๐ Login to docker-hub
- if: github.event_name != 'pull_request'
- uses: docker/login-action@v2
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_TOKEN }}
-
- ### For Cross Platform OSX builds uncomment these lines
- - name: ๐ฅ๏ธ Set up QEMU
- uses: docker/setup-qemu-action@v2
- with:
- platforms: arm64
-
- - name: ๐ Set up Docker BuildX
- uses: docker/setup-buildx-action@v2
- with:
- install: true
-
- - name: ๐ท๏ธ Set tag for docker release image
- if: success() && startsWith(github.ref, 'refs/tags/')
- run: |
- echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-${{ env.VERSION }}" >> "$GITHUB_ENV"
-
- - name: ๐ท๏ธ Set tag for docker master image
- if: success() && ! startsWith(github.ref, 'refs/tags/')
- run: |
- echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest" >> "$GITHUB_ENV"
-
- - name: ๐ ๏ธ Build and export to docker
- uses: docker/build-push-action@v4
- with:
- context: ./dist/${{ env.TEMPLATE }}
- load: true
- tags: ${{ steps.meta.outputs.tags }}
- cache-from: type=registry,ref=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest
- cache-to: type=inline
- labels: ${{ steps.meta.outputs.labels }}
-
- - name: ๐งช Test docker image
- run: |
- export IMAGE_TAG=${{ env.IMAGE_TAG }}; make test
-
- - name: ๐ค Push docker image
- uses: docker/build-push-action@v4
- with:
- context: ./dist/${{ env.TEMPLATE }}
- ### For Cross Platform OSX builds uncomment these lines
- platforms: linux/amd64,linux/arm64
- push: ${{ github.event_name != 'pull_request' }}
- tags: ${{ steps.meta.outputs.tags }}
- cache-from: type=registry,ref=${{ env.IMAGE_TAG }}
- cache-to: type=inline
-
-...
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 2c06814..2276e01 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -1,5 +1,6 @@
---
+# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml
# https://github.com/google-github-actions/release-please-action#release-types-supported
on: # yamllint disable-line rule:truthy
@@ -11,30 +12,12 @@ name: ๐ฆ Create release
jobs:
release:
- runs-on: ubuntu-latest
- steps:
- - name: ๐ Create release
- uses: google-github-actions/release-please-action@v3
- id: release
- with:
- token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
- release-type: node
- package-name: docker-node
- default-branch: master
- changelog-types: |
- [
- { "type": "feat", "section": "Features", "hidden": false },
- { "type": "fix", "section": "Bug Fixes", "hidden": false },
- { "type": "perf", "section": "Performance Improvements", "hidden": false },
- { "type": "docs", "section": "Documentation", "hidden": false },
- { "type": "chore", "section": "Miscellaneous", "hidden": false },
- { "type": "style", "section": "Styles", "hidden": true },
- { "type": "revert", "section": "Reverts", "hidden": true },
- { "type": "deps", "section": "Dependencies", "hidden": true },
- { "type": "refactor", "section": "Code Refactoring", "hidden": true },
- { "type": "test", "section": "Tests", "hidden": true },
- { "type": "build", "section": "Build System", "hidden": true },
- { "type": "ci", "section": "Continuous Integration", "hidden": true }
- ]
+ uses: wayofdev/gh-actions/.github/workflows/create-release.yml@master
+ with:
+ os: ubuntu-latest
+ branch: master
+ package-name: docker-node
+ secrets:
+ token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
...
diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml
index bcfa96d..d23d164 100644
--- a/.github/workflows/shellcheck.yml
+++ b/.github/workflows/shellcheck.yml
@@ -10,17 +10,11 @@ permissions:
jobs:
shellcheck:
- runs-on: ubuntu-latest
- steps:
- - name: ๐ฆ Check out the codebase
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: ๐ Differential shell-check
- uses: redhat-plumbers-in-action/differential-shellcheck@v4
- with:
- severity: warning
- token: ${{ secrets.GITHUB_TOKEN }}
+ uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@master
+ with:
+ os: ubuntu-latest
+ severity: warning
+ secrets:
+ token: ${{ secrets.GITHUB_TOKEN }}
...
diff --git a/.github/workflows/upload-assets.yml b/.github/workflows/upload-assets.yml
index 2abfeb2..0b45081 100644
--- a/.github/workflows/upload-assets.yml
+++ b/.github/workflows/upload-assets.yml
@@ -15,8 +15,6 @@ jobs:
steps:
- name: ๐ฆ Check out the codebase
uses: actions/checkout@v3
- with:
- fetch-depth: 0
- name: ๐ Generate dist files
run: make generate
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8e00b88..15636f1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -8,16 +8,39 @@ repos:
- id: end-of-file-fixer
- id: fix-encoding-pragma
+ - repo: https://github.com/adrienverge/yamllint
+ rev: v1.31.0
+ hooks:
+ - id: yamllint
+ files: \.(yaml|yml)$
+ types: [file, yaml]
+ entry: yamllint --strict
+
- repo: https://github.com/commitizen-tools/commitizen
- rev: v2.42.1
+ rev: 3.2.2
hooks:
- id: commitizen
stages:
- commit-msg
- - repo: https://github.com/rhysd/actionlint
- rev: v1.6.23
+ - repo: https://github.com/ansible/ansible-lint
+ rev: v6.16.1
+ hooks:
+ - id: ansible-lint
+ entry: ansible-lint . --force-color
+ pass_filenames: false
+ always_run: true
+ additional_dependencies:
+ - .[community]
+
+ - repo: https://github.com/robertdebock/pre-commit
+ rev: v1.5.2
hooks:
- - id: actionlint
+ - id: ansible_role_find_unused_variable
+ - id: ansible_role_find_empty_files
+ - id: ansible_role_find_empty_directories
+ - id: ansible_role_fix_readability
+ - id: ansible_role_find_undefined_handlers
+ - id: ansible_role_find_unquoted_values
...
diff --git a/.yamllint b/.yamllint
index 2575b35..3d6a637 100644
--- a/.yamllint
+++ b/.yamllint
@@ -2,9 +2,6 @@
extends: "default"
-ignore: |
- .build/
- vendor/
# Overwrite above default rules
rules:
braces:
diff --git a/Makefile b/Makefile
index 60c77ed..e67067f 100644
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,15 @@ export DOCKER_BUILDKIT ?= 1
export COMPOSE_DOCKER_CLI_BUILD ?= 1
IMAGE_NAMESPACE ?= wayofdev/node
-TEMPLATE ?= 18-alpine
+IMAGE_TEMPLATE ?= 18-alpine
+IMAGE_TAG ?= $(IMAGE_NAMESPACE):$(IMAGE_TEMPLATE)-latest
-IMAGE_TAG ?= $(IMAGE_NAMESPACE):$(TEMPLATE)-latest
-DOCKERFILE_DIR ?= ./dist/$(TEMPLATE)
+DOCKERFILE_DIR ?= ./dist/$(IMAGE_TEMPLATE)
CACHE_FROM ?= $(IMAGE_TAG)
OS ?= $(shell uname)
CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+
# Self documenting Makefile code
# ------------------------------------------------------------------------------------
ifneq ($(TERM),)
@@ -55,7 +56,6 @@ help: ## Show this menu
.EXPORT_ALL_VARIABLES:
-
# Default action
# Defines default command when `make` is executed without additional parameters
# ------------------------------------------------------------------------------------
@@ -63,11 +63,11 @@ all: hooks generate build test
.PHONY: all
-# System Actions
+# Docker Actions
# ------------------------------------------------------------------------------------
build: ## Build default docker image
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
- docker build . -t $(IMAGE_TAG)
+ docker build -t $(IMAGE_TAG) .
PHONY: build
build-from-cache: ## Build default docker image using cached layers
@@ -75,17 +75,11 @@ build-from-cache: ## Build default docker image using cached layers
docker build --cache-from $(CACHE_FROM) . -t $(IMAGE_TAG)
PHONY: build-from-cache
-clean: ## Deletes all files in dist folder
- rm -rf ./dist/*
-PHONY: clean
-
-generate: ## Generate dist files from src folder using ansible playbook
- ansible-playbook src/generate.yml
-PHONY: generate
-
+test: ## Run dgoss tests over docker images
+ set -eux
+ GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
+.PHONY: test
-# Docker Actions
-# ------------------------------------------------------------------------------------
pull: ## Pulls docker image from upstream
docker pull $(IMAGE_TAG)
.PHONY: pull
@@ -99,25 +93,32 @@ ssh: ## Login into built image
.PHONY: ssh
-# Testing and Code Quality
+# Ansible Actions
# ------------------------------------------------------------------------------------
-test: ## Run dgoss tests over docker images
- set -eux
- GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
-.PHONY: test
-
-lint-docker: ## Run hadolint over dist Dockerfiles
- hadolint -V ./dist/$(TEMPLATE)/Dockerfile
-.PHONY: lint-docker
+generate: ## Generate dist files from src folder using ansible playbook
+ ansible-playbook src/playbook.yml
+PHONY: generate
-lint-yaml: ## Lints yaml files inside project
- yamllint .
-.PHONY: lint
+clean: ## Deletes all files in dist folder
+ rm -rf ./dist/*
+PHONY: clean
-# Git Actions
+# Code Quality, Git, Linting, Testing
# ------------------------------------------------------------------------------------
hooks: ## Install git hooks from pre-commit-config
pre-commit install
pre-commit autoupdate
.PHONY: hooks
+
+lint-yaml: ## Lints yaml files inside project
+ yamllint .
+.PHONY: lint
+
+lint-ansible: ## Lint ansible files inside project
+ ansible-lint .
+.PHONY: lint-ansible
+
+lint-docker: ## Run hadolint over dist Dockerfiles
+ hadolint -V ./dist/$(IMAGE_TEMPLATE)/Dockerfile
+.PHONY: lint-docker
diff --git a/README.md b/README.md
index fdb1eaf..49c07e3 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
@@ -76,9 +76,9 @@ $ make
To build all images, run the following commands:
```bash
-$ make build TEMPLATE="lts-alpine"
-$ make build TEMPLATE="19-alpine"
-$ make build TEMPLATE="18-alpine"
+$ make build IMAGE_TEMPLATE="lts-alpine"
+$ make build IMAGE_TEMPLATE="19-alpine"
+$ make build IMAGE_TEMPLATE="18-alpine"
```
@@ -94,9 +94,9 @@ $ make test
To test all images, run the following commands:
```bash
-$ make test TEMPLATE="lts-alpine"
-$ make test TEMPLATE="19-alpine"
-$ make test TEMPLATE="18-alpine"
+$ make test IMAGE_TEMPLATE="lts-alpine"
+$ make test IMAGE_TEMPLATE="19-alpine"
+$ make test IMAGE_TEMPLATE="18-alpine"
```
@@ -138,4 +138,3 @@ This repository was created in **2022** by [lotyp / wayofdev](https://github.com
-
diff --git a/src/Dockerfiles/all/goss.yaml.j2 b/src/Dockerfiles/all/goss.yaml.j2
index 9e293e2..2a163cd 100644
--- a/src/Dockerfiles/all/goss.yaml.j2
+++ b/src/Dockerfiles/all/goss.yaml.j2
@@ -7,7 +7,7 @@ command:
exit-status: 0
"curl --version":
stdout:
- - "curl 7"
+ - "curl 8"
exit-status: 0
"pnpm --version":
stdout:
diff --git a/src/inventory.yml b/src/inventory.yml
index 1e3e1de..5ba1379 100644
--- a/src/inventory.yml
+++ b/src/inventory.yml
@@ -8,9 +8,9 @@ all:
ansible_connection: local
node_version: lts
os_name: alpine
- 19-alpine:
+ 20-alpine:
ansible_connection: local
- node_version: 19
+ node_version: 20
os_name: alpine
18-alpine:
ansible_connection: local
diff --git a/src/generate.yml b/src/playbook.yml
similarity index 100%
rename from src/generate.yml
rename to src/playbook.yml
diff --git a/src/roles/all/main.yml b/src/roles/all/main.yml
index 823b010..4163146 100644
--- a/src/roles/all/main.yml
+++ b/src/roles/all/main.yml
@@ -1,7 +1,7 @@
---
- name: Create dist directories
- file:
+ ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0775
@@ -10,7 +10,7 @@
- "{{ tpl_directories }}"
- name: Get latest pnpm version
- shell: cat ./../package.json | jq -r '.dependencies."pnpm"'
+ ansible.builtin.shell: cat ./../package.json | jq -r '.dependencies."pnpm"'
register: pnpm_version
changed_when: false
@@ -19,7 +19,7 @@
pnpm_version: "{{ pnpm_version.stdout | regex_replace('^(\\^)', '') }}"
- name: Generate Dockerfiles
- template:
+ ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dst }}"
force: true
@@ -28,7 +28,7 @@
- "{{ tpl_dockerfiles }}"
- name: Generate Dockerfile dgoss tests
- template:
+ ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dst }}"
force: true