Skip to content

Commit 141e2ce

Browse files
committedMar 14, 2023
feat: updating workflow
1 parent a0ae999 commit 141e2ce

18 files changed

+198
-224
lines changed
 

‎.github/dependabot.yml

-14
This file was deleted.

‎.github/labeler.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
3+
# this file is for the labeler workflow job
4+
# Documentation https://github.com/marketplace/actions/labeler
5+
6+
"type: documentation":
7+
- assets/**/*
8+
- .github/*
9+
- ./*.md
10+
11+
"type: maintenance":
12+
- .dependabot/*
13+
- .github/workflows/*
14+
- src/**/goss.yaml.j2
15+
16+
...
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
3+
# https://github.com/peter-evans/enable-pull-request-automerge
4+
5+
on: # yamllint disable-line rule:truthy
6+
pull_request:
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
12+
name: 🤞 Auto merge release
13+
14+
jobs:
15+
auto-merge:
16+
if: github.actor == 'lotyp' && startsWith(github.head_ref, 'release-please--')
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: 🤞 Auto-merge pull request
20+
uses: peter-evans/enable-pull-request-automerge@v2
21+
with:
22+
pull-request-number: ${{ github.event.pull_request.number }}
23+
merge-method: merge
24+
# to trigger other workflows, pass PAT token instead of GITHUB_TOKEN
25+
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
26+
27+
...

‎.github/workflows/ci.yml

+39-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---
22

3-
name: CI
4-
53
on: # yamllint disable-line rule:truthy
64
push:
75
branches:
@@ -18,31 +16,40 @@ on: # yamllint disable-line rule:truthy
1816
# Every Tuesday at 03:10
1917
- cron: '10 3 * * 2'
2018

19+
name: 🔍 Continuous integration
20+
2121
jobs:
2222
build:
23-
name: Build
2423
runs-on: ubuntu-latest
2524
strategy:
2625
fail-fast: false
2726
matrix:
2827
rabbitmq_version: ['alpine', 'management-alpine']
2928
steps:
30-
- uses: e1himself/goss-installation-action@v1.1.0
29+
- name: 📦 Install goss
30+
uses: e1himself/goss-installation-action@v1.1.0
31+
32+
- name: 📦 Check out the codebase
33+
uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0
3136

32-
- name: Checkout
33-
uses: actions/checkout@v3.2.0
37+
- name: 🤖 Generate dist files
38+
run: make generate
3439

35-
- name: Set Environment Variables
40+
- name: 🌎 Set environment variables
3641
env:
3742
IMAGE_NAMESPACE: wayofdev/rabbitmq
3843
TEMPLATE: ${{ matrix.rabbitmq_version }}
3944
run: |
40-
export RELEASE_VERSION=${GITHUB_REF#refs/*/}
41-
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}" >> $GITHUB_ENV
42-
echo "TEMPLATE=${TEMPLATE}" >> $GITHUB_ENV
43-
echo "VERSION=${RELEASE_VERSION:1}" >> $GITHUB_ENV
45+
export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
46+
&& { \
47+
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
48+
echo "TEMPLATE=${TEMPLATE}"; \
49+
echo "VERSION=${RELEASE_VERSION:1}"; \
50+
} >> "$GITHUB_ENV"
4451
45-
- name: Docker Meta
52+
- name: 🐳 Define docker meta
4653
id: meta
4754
uses: docker/metadata-action@v4
4855
with:
@@ -56,46 +63,50 @@ jobs:
5663
latest=false
5764
prefix=${{ matrix.rabbitmq_version }}-
5865
59-
- name: Login to DockerHub
66+
- name: 🔑 Login to docker-hub
6067
if: github.event_name != 'pull_request'
6168
uses: docker/login-action@v2
6269
with:
6370
username: ${{ secrets.DOCKER_USERNAME }}
6471
password: ${{ secrets.DOCKER_TOKEN }}
6572

6673
### For Cross Platform OSX builds uncomment these lines
67-
- name: Set up QEMU
74+
- name: 🖥️ Set up QEMU
6875
uses: docker/setup-qemu-action@v2.1.0
6976
with:
7077
platforms: arm64
7178

72-
- name: Set up Docker Buildx
79+
- name: 🚀 Set up Docker BuildX
7380
uses: docker/setup-buildx-action@v2
7481
with:
7582
install: true
7683

77-
- name: Build and Export to Docker
78-
uses: docker/build-push-action@v3
84+
- name: 🏷️ Set tag for docker release image
85+
if: success() && startsWith(github.ref, 'refs/tags/')
86+
run: |
87+
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-${{ env.VERSION }}" >> "$GITHUB_ENV"
88+
89+
- name: 🏷️ Set tag for docker master image
90+
if: success() && ! startsWith(github.ref, 'refs/tags/')
91+
run: |
92+
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest" >> "$GITHUB_ENV"
93+
94+
- name: 🛠️ Build and export to docker
95+
uses: docker/build-push-action@v4
7996
with:
8097
context: ./dist/${{ env.TEMPLATE }}
8198
load: true
8299
tags: ${{ steps.meta.outputs.tags }}
83-
cache-from: type=registry,ref=${{ env.IMAGE_TAG }}
100+
cache-from: type=registry,ref=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest
84101
cache-to: type=inline
85102
labels: ${{ steps.meta.outputs.labels }}
86103

87-
- name: Test Docker Release Image
88-
if: success() && startsWith(github.ref, 'refs/tags/')
89-
run: |
90-
IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-${{ env.VERSION }} make test
91-
92-
- name: Test Docker Master Image
93-
if: success() && ! startsWith(github.ref, 'refs/tags/')
104+
- name: 🧪 Test docker image
94105
run: |
95-
IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest make test
106+
export IMAGE_TAG=${{ env.IMAGE_TAG }}; make test
96107
97-
- name: Push Docker Image
98-
uses: docker/build-push-action@v3
108+
- name: 📤 Push docker image
109+
uses: docker/build-push-action@v4
99110
with:
100111
context: ./dist/${{ env.TEMPLATE }}
101112
### For Cross Platform OSX builds uncomment these lines

‎.github/workflows/release-please.yml renamed to ‎.github/workflows/create-release.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ on: # yamllint disable-line rule:truthy
77
branches:
88
- master
99

10-
name: release-please
10+
name: 📦 Create release
1111

1212
jobs:
13-
release-please:
13+
release:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: google-github-actions/release-please-action@v3
16+
- name: 🎉 Create release
17+
uses: google-github-actions/release-please-action@v3
1718
id: release
1819
with:
1920
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}

‎.github/workflows/label.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
3+
# This workflow will triage pull requests and apply a label based on the
4+
# paths that are modified in the pull request.
5+
#
6+
# To use this workflow, you will need to set up a .github/labeler.yml
7+
# file with configuration. For more information, see:
8+
# https://github.com/actions/labeler/blob/master/README.md
9+
10+
on: # yamllint disable-line rule:truthy
11+
pull_request:
12+
13+
name: 🏷️ Add labels
14+
15+
jobs:
16+
label:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: 🏷️ Apply labels
20+
uses: actions/labeler@v4
21+
with:
22+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
23+
24+
...

‎.github/workflows/shellcheck.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
---
22

3-
name: Differential ShellCheck
4-
53
on: # yamllint disable-line rule:truthy
64
pull_request:
75

6+
name: 🐞 Differential shell-check
7+
88
permissions:
99
contents: read
1010

1111
jobs:
1212
shellcheck:
1313
runs-on: ubuntu-latest
14-
1514
steps:
16-
- name: Repository checkout
17-
uses: actions/checkout@v3.2.0
15+
- name: 📦 Check out the codebase
16+
uses: actions/checkout@v3
1817
with:
1918
fetch-depth: 0
2019

21-
- name: Differential ShellCheck
22-
uses: redhat-plumbers-in-action/differential-shellcheck@v3
20+
- name: 🐞 Differential shell-check
21+
uses: redhat-plumbers-in-action/differential-shellcheck@v4
2322
with:
2423
severity: warning
2524
token: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/upload-assets.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
3+
# https://github.com/google-github-actions/release-please-action#release-types-supported
4+
5+
on: # yamllint disable-line rule:truthy
6+
push:
7+
tags:
8+
- "v*.*.*"
9+
10+
name: 📤 Upload artifacts
11+
12+
jobs:
13+
upload-artifacts:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: 📦 Check out the codebase
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: 🚀 Generate dist files
22+
run: make generate
23+
24+
- name: 🗜️ Archive dist files
25+
run: tar -czvf dist.tar.gz dist
26+
27+
- name: 📤 Upload release assets
28+
uses: alexellis/upload-assets@0.4.0
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
asset_paths: '["./dist.tar.gz"]'
33+
34+
...

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
/dist

‎.pre-commit-config.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
5+
rev: v4.4.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: fix-encoding-pragma
1010

1111
- repo: https://github.com/commitizen-tools/commitizen
12-
rev: v2.37.0
12+
rev: v2.42.1
1313
hooks:
1414
- id: commitizen
1515
stages:
1616
- commit-msg
1717

18+
- repo: https://github.com/rhysd/actionlint
19+
rev: v1.6.23
20+
hooks:
21+
- id: actionlint
22+
1823
...

‎Makefile

+38-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
# BuildKit enables higher performance docker builds and caching possibility
2+
# to decrease build times and increase productivity for free.
13
export DOCKER_BUILDKIT ?= 1
4+
export COMPOSE_DOCKER_CLI_BUILD ?= 1
5+
26
IMAGE_NAMESPACE ?= wayofdev/rabbitmq
37
TEMPLATE ?= alpine
48

@@ -8,6 +12,8 @@ CACHE_FROM ?= $(IMAGE_TAG)
812
OS ?= $(shell uname)
913
CURRENT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1014

15+
# Self documenting Makefile code
16+
# ------------------------------------------------------------------------------------
1117
ifneq ($(TERM),)
1218
BLACK := $(shell tput setaf 0)
1319
RED := $(shell tput setaf 1)
@@ -48,9 +54,15 @@ help:
4854
.PHONY: help
4955

5056

51-
all: build test
52-
PHONY: all
57+
# Default action
58+
# Defines default command when `make` is executed without additional parameters
59+
# ------------------------------------------------------------------------------------
60+
all: hooks generate build test
61+
.PHONY: all
62+
5363

64+
# System Actions
65+
# ------------------------------------------------------------------------------------
5466
build: ## Build default docker image
5567
cd $(CURRENT_DIR)$(DOCKERFILE_DIR); \
5668
docker buildx build \
@@ -68,11 +80,17 @@ build-from-cache: ## Build default docker image using cached layers
6880
--push .
6981
PHONY: build-from-cache
7082

71-
test: ## Run dgoss tests over docker images
72-
set -eux
73-
GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
74-
.PHONY: test
83+
clean: ## Deletes all files in dist folder
84+
rm -rf ./dist/*
85+
PHONY: clean
86+
87+
generate: ## Generate dist files from src folder using ansible playbook
88+
ansible-playbook src/generate.yml
89+
PHONY: generate
7590

91+
92+
# Docker Actions
93+
# ------------------------------------------------------------------------------------
7694
pull: ## Pulls docker image from upstream
7795
docker pull $(IMAGE_TAG)
7896
.PHONY: pull
@@ -85,32 +103,26 @@ ssh: ## Login into built image
85103
docker run --rm -it -v $(PWD)/:/opt/rabbitmq $(IMAGE_TAG) sh
86104
.PHONY: ssh
87105

88-
hadolint: ## Run hadolint over dist Dockerfiles
89-
hadolint -V ./dist/alpine/Dockerfile
90-
.PHONY: hadolint
91-
92106

93-
# Git Actions
107+
# Testing and Code Quality
94108
# ------------------------------------------------------------------------------------
95-
hooks: ## Install git hooks from pre-commit-config
96-
pre-commit install
97-
pre-commit autoupdate
98-
.PHONY: hooks
109+
test: ## Run dgoss tests over docker images
110+
set -eux
111+
GOSS_FILES_STRATEGY=cp GOSS_FILES_PATH=$(DOCKERFILE_DIR) dgoss run --add-host app:127.0.0.1 -t $(IMAGE_TAG)
112+
.PHONY: test
99113

114+
lint-docker: ## Run hadolint over dist Dockerfiles
115+
hadolint -V ./dist/$(TEMPLATE)/Dockerfile
116+
.PHONY: lint-docker
100117

101-
# Yaml Actions
102-
# ------------------------------------------------------------------------------------
103-
lint: ## Lints yaml files inside project
118+
lint-yaml: ## Lints yaml files inside project
104119
yamllint .
105120
.PHONY: lint
106121

107122

108-
# Ansible Actions
123+
# Git Actions
109124
# ------------------------------------------------------------------------------------
110-
generate: ## Generate dist files from src folder using ansible playbook
111-
ansible-playbook src/generate.yml
112-
PHONY: generate
113-
114-
clean: ## Deletes all files in dist folder
115-
rm -rf ./dist/*
116-
PHONY: clean
125+
hooks: ## Install git hooks from pre-commit-config
126+
pre-commit install
127+
pre-commit autoupdate
128+
.PHONY: hooks

‎README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ $ make test TEMPLATE="management-alpine"
102102
Run **yamllint** to validate all yaml files in project:
103103

104104
```bash
105-
$ make lint
105+
$ make lint-yaml
106106
```
107107

108108
Run hadolint to validate created Dockerfiles:
109109

110110
```bash
111-
$ make hadolint
111+
$ make lint-docker
112112
```
113113

114114
<br>
@@ -134,4 +134,3 @@ This repository was created in **2022** by [lotyp / wayofdev](https://github.com
134134
</a>
135135

136136
<br>
137-

‎dist/alpine/Dockerfile

-40
This file was deleted.

‎dist/alpine/goss.yaml

-22
This file was deleted.

‎dist/alpine/goss_wait.yaml

-7
This file was deleted.

‎dist/management-alpine/Dockerfile

-41
This file was deleted.

‎dist/management-alpine/goss.yaml

-24
This file was deleted.

‎dist/management-alpine/goss_wait.yaml

-7
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.