Skip to content

Commit 36fa26f

Browse files
authored
Merge pull request #81 from puppetlabs/refactor-docs-and-deployment
[WIP] Refactor docs and deployment
2 parents ef4c3ed + 91c3c98 commit 36fa26f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+761
-747
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
11
version: 2
22
updates:
3-
# /docker/dev folder
43
- package-ecosystem: docker
5-
directory: "/docker/dev/"
4+
directory: "/docker/"
65
schedule:
7-
interval: daily
8-
time: "13:00"
6+
interval: weekly
97
open-pull-requests-limit: 10
10-
# /docker/prod-all-providers folder
8+
119
- package-ecosystem: bundler
12-
directory: "/docker/prod-all-providers/"
10+
directory: "/docker/"
1311
schedule:
14-
interval: daily
15-
time: "13:00"
16-
open-pull-requests-limit: 10
17-
- package-ecosystem: docker
18-
directory: "/docker/prod-all-providers/"
19-
schedule:
20-
interval: daily
21-
time: "13:00"
22-
open-pull-requests-limit: 10
23-
# /docker/test-all-providers folder
24-
- package-ecosystem: bundler
25-
directory: "/docker/test-all-providers/"
26-
schedule:
27-
interval: daily
28-
time: "13:00"
29-
open-pull-requests-limit: 10
30-
- package-ecosystem: docker
31-
directory: "/docker/test-all-providers/"
32-
schedule:
33-
interval: daily
34-
time: "13:00"
12+
interval: weekly
3513
open-pull-requests-limit: 10

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Docker Build
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: read
7+
packages: write
8+
9+
jobs:
10+
build:
11+
name: Docker Build and Push
12+
if: contains(github.event.pull_request.labels.*.name, 'documentation') != true
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.ref }}
19+
clean: true
20+
fetch-depth: 0
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v2
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Build and push
33+
uses: docker/build-push-action@v3
34+
with:
35+
context: docker
36+
push: true
37+
tags: ghcr.io/${{ github.repository }}/vmpooler:pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}

.github/workflows/container-all-prod-providers.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/release-helm-charts.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Docker and Helm Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
issues: read
9+
pull-requests: read
10+
packages: write
11+
12+
jobs:
13+
release:
14+
name: Validate Docs, Tag, and Docker Push & Helm Push
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
token: ${{ secrets.BOT_TOKEN }}
20+
21+
- name: Get New Chart Version
22+
id: nv
23+
run: |
24+
version=$(yq .version helm-charts/vmpooler/Chart.yaml)
25+
appVersion=$(yq .appVersion helm-charts/vmpooler/Chart.yaml)
26+
echo "version=$version" >> $GITHUB_OUTPUT
27+
echo "appVersion=$appVersion" >> $GITHUB_OUTPUT
28+
echo "Found version $version from helm-charts/vmpooler/Chart.yaml"
29+
echo "Found appVersion $appVersion from helm-charts/vmpooler/Chart.yaml"
30+
31+
- name: Get Current Chart Version
32+
uses: actions/github-script@v6
33+
id: cv
34+
with:
35+
script: |
36+
const { data: response } = await github.rest.repos.getLatestRelease({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
})
40+
console.log(`The latest release is ${response.tag_name}`)
41+
return response.tag_name
42+
result-encoding: string
43+
44+
- name: Get Current Docker Tag
45+
uses: actions/github-script@v6
46+
id: dv
47+
with:
48+
script: |
49+
// concat to build "vmpooler-deployment%2Fvmpooler"
50+
const packageName = [context.repo.repo, 'vmpooler'].join('/');
51+
52+
const shouldRunDockerBuild = async () => {
53+
let runDockerBuild = true;
54+
// Iterate through all pages of list of package versions
55+
for await (const response of github.paginate.iterator(
56+
github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
57+
{
58+
package_type: 'container',
59+
package_name: packageName,
60+
org: context.repo.owner,
61+
}
62+
)) {
63+
// Loop through each version, destructure down to the tags array and search for existing tag
64+
for (const data of response.data) {
65+
const { metadata: { container: { tags }}} = data;
66+
console.log('List of docker tags:', tags);
67+
if (tags.includes("${{ steps.nv.outputs.appVersion }}")) {
68+
// Existing tag found, return false so that docker build does not run
69+
console.log('Found existing tag for', "${{ steps.nv.outputs.appVersion }}");
70+
runDockerBuild = false;
71+
break;
72+
};
73+
};
74+
};
75+
return runDockerBuild;
76+
};
77+
78+
const returnValue = await shouldRunDockerBuild();
79+
console.log('return:', returnValue);
80+
return returnValue;
81+
82+
- name: Generate Changelog
83+
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
84+
with:
85+
args: >-
86+
--future-release ${{ steps.nv.outputs.version }}
87+
env:
88+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Validate Changelog
91+
run : |
92+
set -e
93+
if [[ -n $(git status --porcelain) ]]; then
94+
echo "Here is the current git status:"
95+
git status
96+
echo
97+
echo "The following changes were detected:"
98+
git --no-pager diff
99+
echo "Uncommitted PRs found in the changelog. Please submit a release prep PR of changes after running 'docker run -it --rm -e CHANGELOG_GITHUB_TOKEN -v "\$\(pwd\)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator:1.16.2 github_changelog_generator --future-release ${{ steps.nv.outputs.version }}'"
100+
exit 1
101+
fi
102+
103+
- name: Generate Release Notes
104+
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
105+
with:
106+
args: >-
107+
--since-tag ${{ steps.cv.outputs.result }}
108+
--future-release ${{ steps.nv.outputs.version }}
109+
--output release-notes.md
110+
env:
111+
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Tag Release
114+
uses: ncipollo/release-action@v1
115+
with:
116+
tag: ${{ steps.nv.outputs.version }}
117+
token: ${{ secrets.GITHUB_TOKEN }}
118+
bodyfile: release-notes.md
119+
draft: false
120+
prerelease: false
121+
122+
- name: Set up Docker Buildx
123+
uses: docker/setup-buildx-action@v2
124+
125+
- name: Login to GitHub Container Registry
126+
uses: docker/login-action@v2
127+
with:
128+
registry: ghcr.io
129+
username: ${{ github.actor }}
130+
password: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Build and push Docker
133+
if: ${{ steps.dv.outputs.result == 'true' }}
134+
uses: docker/build-push-action@v3
135+
with:
136+
push: true
137+
tags: |
138+
ghcr.io/${{ github.repository }}:${{ steps.nv.outputs.appVersion }}
139+
ghcr.io/${{ github.repository }}:latest
140+
141+
- uses: azure/setup-helm@v3
142+
143+
- uses: actions/setup-python@v4
144+
with:
145+
python-version: 3.9
146+
147+
- name: Package Helm charts
148+
run: |
149+
set -e
150+
cd docs/
151+
helm package ../helm-charts/*
152+
helm repo index --url https://puppetlabs.github.io/vmpooler-deployment/ .
153+
154+
- name: Git Commit and Push Helm Charts
155+
run: |
156+
git config user.name "puppetlabs-jenkins"
157+
git config user.email "[email protected]"
158+
git --no-pager diff CHANGELOG.md
159+
git add CHANGELOG.md
160+
git commit -m "release helm-chart version ${{ steps.nv.outputs.version }}"
161+
git push

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Helm Test
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: Test Helm Chart
8+
if: contains(github.event.pull_request.labels.*.name, 'documentation') != true
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
with:
14+
ref: ${{ github.ref }}
15+
clean: true
16+
fetch-depth: 0
17+
18+
- uses: azure/setup-helm@v3
19+
20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.9
23+
24+
- name: Set up chart-testing
25+
uses: helm/chart-testing-action@v2
26+
27+
- name: Run chart-testing (lint)
28+
run: ct lint --chart-dirs helm-charts --all --validate-maintainers=false --chart-repos bitnami=https://charts.bitnami.com/bitnami

.github_changelog_generator

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project=vmpooler-deployment
2+
user=puppetlabs
3+
exclude_labels=maintenance

0 commit comments

Comments
 (0)