mirror of
https://github.com/puppetlabs/vmpooler-deployment.git
synced 2026-01-25 19:18:42 -05:00
Add test and release workflow
This commit is contained in:
parent
f1563ed601
commit
91c3c98904
4 changed files with 189 additions and 115 deletions
|
|
@ -1,47 +0,0 @@
|
|||
---
|
||||
name: Container with all prod providers
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag in semver format'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
container_prod_all_providers:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2 # Checking out the repo
|
||||
- name: Build and Publish Docker image
|
||||
uses: VaultVulp/gp-docker-action@1.2.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
image-name: vmpooler
|
||||
build-context: ./docker/prod-all-providers/
|
||||
dockerfile: ./docker/prod-all-providers/Dockerfile
|
||||
image-tag: ${{ github.event.inputs.tag }}-prod-all-providers
|
||||
- name: Generate Release Body
|
||||
env:
|
||||
RELEASE_BODY_FILE: "${{ github.event.inputs.tag }}-prod-all-providers-release-body.md"
|
||||
run: |
|
||||
echo "## Components" > ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "This release includes the following:" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "### Source image" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "- $(grep ^FROM ./docker/prod-all-providers/Dockerfile |cut -d ' ' -f2) + OS updates" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "### Gems" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "$(grep -e 'vmpooler ([0-9]' docker/prod-all-providers/Gemfile.lock | xargs -L1 echo -)" >> ${RELEASE_BODY_FILE}
|
||||
echo "$(grep -e 'vmpooler-provider-.* ([0-9]' docker/prod-all-providers/Gemfile.lock | xargs -L1 echo -)" >> ${RELEASE_BODY_FILE}
|
||||
- name: Tag Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: ${{ github.event.inputs.tag }}-prod-all-providers
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
bodyFile: ${{ github.event.inputs.tag }}-prod-all-providers-release-body.md
|
||||
generateReleaseNotes: true
|
||||
68
.github/workflows/release-helm-charts.yml
vendored
68
.github/workflows/release-helm-charts.yml
vendored
|
|
@ -1,68 +0,0 @@
|
|||
---
|
||||
name: Release Helm charts
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag in semver format'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
container_prod_all_providers:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # ct list-changed below needs this
|
||||
- uses: azure/setup-helm@v1
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Set up chart-testing
|
||||
uses: helm/chart-testing-action@v2.1.0
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
run: |
|
||||
changed=$(ct list-changed --chart-dirs helm-charts --target-branch main)
|
||||
if [[ -n "$changed" ]]; then
|
||||
echo "::set-output name=changed::true"
|
||||
fi
|
||||
- name: Run chart-testing (lint)
|
||||
run: ct lint --chart-dirs helm-charts --all --validate-maintainers=false --chart-repos bitnami=https://charts.bitnami.com/bitnami
|
||||
- name: Package charts
|
||||
run: |
|
||||
set -e
|
||||
cd docs/
|
||||
helm package ../helm-charts/*
|
||||
helm repo index --url https://puppetlabs.github.io/vmpooler-deployment/ .
|
||||
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version.
|
||||
with:
|
||||
add: docs
|
||||
message: release helm-chart version ${{ github.event.inputs.tag }}
|
||||
- name: Generate Release Body
|
||||
env:
|
||||
RELEASE_BODY_FILE: "${{ github.event.inputs.tag }}-prod-all-providers-release-body.md"
|
||||
run: |
|
||||
echo "#Components" > ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "This release includes the following:" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "##Source image" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "- $(grep ^FROM ./docker/prod-all-providers/Dockerfile |cut -d ' ' -f2) + OS updates" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "##Gems" >> ${RELEASE_BODY_FILE}
|
||||
echo "" >> ${RELEASE_BODY_FILE}
|
||||
echo "$(grep -e 'vmpooler ([0-9]' docker/prod-all-providers/Gemfile.lock | xargs -L1 echo -)" >> ${RELEASE_BODY_FILE}
|
||||
echo "$(grep -e 'vmpooler-provider-.* ([0-9]' docker/prod-all-providers/Gemfile.lock | xargs -L1 echo -)" >> ${RELEASE_BODY_FILE}
|
||||
echo "${RELEASE_BODY_FILE}"
|
||||
- name: Tag Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: ${{ github.event.inputs.tag }}-prod-all-providers
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
bodyFile: ${{ github.event.inputs.tag }}-prod-all-providers-release-body.md
|
||||
generateReleaseNotes: true
|
||||
161
.github/workflows/release.yml
vendored
Normal file
161
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
name: Docker and Helm Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: read
|
||||
pull-requests: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Validate Docs, Tag, and Docker Push & Helm Push
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.BOT_TOKEN }}
|
||||
|
||||
- name: Get New Chart Version
|
||||
id: nv
|
||||
run: |
|
||||
version=$(yq .version helm-charts/vmpooler/Chart.yaml)
|
||||
appVersion=$(yq .appVersion helm-charts/vmpooler/Chart.yaml)
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
echo "appVersion=$appVersion" >> $GITHUB_OUTPUT
|
||||
echo "Found version $version from helm-charts/vmpooler/Chart.yaml"
|
||||
echo "Found appVersion $appVersion from helm-charts/vmpooler/Chart.yaml"
|
||||
|
||||
- name: Get Current Chart Version
|
||||
uses: actions/github-script@v6
|
||||
id: cv
|
||||
with:
|
||||
script: |
|
||||
const { data: response } = await github.rest.repos.getLatestRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
})
|
||||
console.log(`The latest release is ${response.tag_name}`)
|
||||
return response.tag_name
|
||||
result-encoding: string
|
||||
|
||||
- name: Get Current Docker Tag
|
||||
uses: actions/github-script@v6
|
||||
id: dv
|
||||
with:
|
||||
script: |
|
||||
// concat to build "vmpooler-deployment%2Fvmpooler"
|
||||
const packageName = [context.repo.repo, 'vmpooler'].join('/');
|
||||
|
||||
const shouldRunDockerBuild = async () => {
|
||||
let runDockerBuild = true;
|
||||
// Iterate through all pages of list of package versions
|
||||
for await (const response of github.paginate.iterator(
|
||||
github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
|
||||
{
|
||||
package_type: 'container',
|
||||
package_name: packageName,
|
||||
org: context.repo.owner,
|
||||
}
|
||||
)) {
|
||||
// Loop through each version, destructure down to the tags array and search for existing tag
|
||||
for (const data of response.data) {
|
||||
const { metadata: { container: { tags }}} = data;
|
||||
console.log('List of docker tags:', tags);
|
||||
if (tags.includes("${{ steps.nv.outputs.appVersion }}")) {
|
||||
// Existing tag found, return false so that docker build does not run
|
||||
console.log('Found existing tag for', "${{ steps.nv.outputs.appVersion }}");
|
||||
runDockerBuild = false;
|
||||
break;
|
||||
};
|
||||
};
|
||||
};
|
||||
return runDockerBuild;
|
||||
};
|
||||
|
||||
const returnValue = await shouldRunDockerBuild();
|
||||
console.log('return:', returnValue);
|
||||
return returnValue;
|
||||
|
||||
- name: Generate Changelog
|
||||
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
|
||||
with:
|
||||
args: >-
|
||||
--future-release ${{ steps.nv.outputs.version }}
|
||||
env:
|
||||
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Validate Changelog
|
||||
run : |
|
||||
set -e
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "Here is the current git status:"
|
||||
git status
|
||||
echo
|
||||
echo "The following changes were detected:"
|
||||
git --no-pager diff
|
||||
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 }}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Generate Release Notes
|
||||
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
|
||||
with:
|
||||
args: >-
|
||||
--since-tag ${{ steps.cv.outputs.result }}
|
||||
--future-release ${{ steps.nv.outputs.version }}
|
||||
--output release-notes.md
|
||||
env:
|
||||
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Tag Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: ${{ steps.nv.outputs.version }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
bodyfile: release-notes.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Docker
|
||||
if: ${{ steps.dv.outputs.result == 'true' }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:${{ steps.nv.outputs.appVersion }}
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
|
||||
- uses: azure/setup-helm@v3
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- name: Package Helm charts
|
||||
run: |
|
||||
set -e
|
||||
cd docs/
|
||||
helm package ../helm-charts/*
|
||||
helm repo index --url https://puppetlabs.github.io/vmpooler-deployment/ .
|
||||
|
||||
- name: Git Commit and Push Helm Charts
|
||||
run: |
|
||||
git config user.name "puppetlabs-jenkins"
|
||||
git config user.email "team-quality-engineering@puppet.com"
|
||||
git --no-pager diff CHANGELOG.md
|
||||
git add CHANGELOG.md
|
||||
git commit -m "release helm-chart version ${{ steps.nv.outputs.version }}"
|
||||
git push
|
||||
28
.github/workflows/test.yml
vendored
Normal file
28
.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
name: Helm Test
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Helm Chart
|
||||
if: contains(github.event.pull_request.labels.*.name, 'documentation') != true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
clean: true
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: azure/setup-helm@v3
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- name: Set up chart-testing
|
||||
uses: helm/chart-testing-action@v2
|
||||
|
||||
- name: Run chart-testing (lint)
|
||||
run: ct lint --chart-dirs helm-charts --all --validate-maintainers=false --chart-repos bitnami=https://charts.bitnami.com/bitnami
|
||||
Loading…
Add table
Add a link
Reference in a new issue