Skip to content

Commit e40dc66

Browse files
author
jordanbreen28
committed
(CONT-229) - Implement reusable workflows
1 parent 3176fcf commit e40dc66

File tree

5 files changed

+24
-390
lines changed

5 files changed

+24
-390
lines changed

.github/workflows/auto_release.yml

Lines changed: 4 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -3,88 +3,8 @@ name: "Auto release"
33
on:
44
workflow_dispatch:
55

6-
env:
7-
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
8-
HONEYCOMB_DATASET: litmus tests
9-
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10-
116
jobs:
12-
auto_release:
13-
name: "Automatic release prep"
14-
runs-on: ubuntu-20.04
15-
16-
steps:
17-
18-
- name: "Honeycomb: Start recording"
19-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
20-
with:
21-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
22-
dataset: ${{ env.HONEYCOMB_DATASET }}
23-
job-status: ${{ job.status }}
24-
25-
- name: "Honeycomb: start first step"
26-
run: |
27-
echo STEP_ID="auto-release" >> $GITHUB_ENV
28-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
29-
- name: "Checkout Source"
30-
if: ${{ github.repository_owner == 'puppetlabs' }}
31-
uses: actions/checkout@v2
32-
with:
33-
fetch-depth: 0
34-
persist-credentials: false
35-
36-
- name: "PDK Release prep"
37-
uses: docker://puppet/pdk:2.6.1.0
38-
with:
39-
args: 'release prep --force'
40-
env:
41-
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
43-
- name: "Get Version"
44-
if: ${{ github.repository_owner == 'puppetlabs' }}
45-
id: gv
46-
run: |
47-
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
48-
49-
- name: "Check if a release is necessary"
50-
if: ${{ github.repository_owner == 'puppetlabs' }}
51-
id: check
52-
run: |
53-
git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true"
54-
55-
- name: "Commit changes"
56-
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
57-
run: |
58-
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
59-
git config --local user.name "GitHub Action"
60-
git add .
61-
git commit -m "Release prep v${{ steps.gv.outputs.ver }}"
62-
63-
- name: Create Pull Request
64-
id: cpr
65-
uses: puppetlabs/peter-evans-create-pull-request@v3
66-
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
67-
with:
68-
token: ${{ secrets.GITHUB_TOKEN }}
69-
commit-message: "Release prep v${{ steps.gv.outputs.ver }}"
70-
branch: "release-prep"
71-
delete-branch: true
72-
title: "Release prep v${{ steps.gv.outputs.ver }}"
73-
body: |
74-
Automated release-prep through [pdk-templates](https://github.com/puppetlabs/pdk-templates/blob/main/moduleroot/.github/workflows/auto_release.yml.erb) from commit ${{ github.sha }}.
75-
Please verify before merging:
76-
- [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green
77-
- [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests
78-
- [ ] Ensure the [changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) version and [metadata](https://github.com/${{ github.repository }}/blob/release-prep/metadata.json) version match
79-
labels: "maintenance"
80-
81-
- name: PR outputs
82-
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
83-
run: |
84-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
85-
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
86-
87-
- name: "Honeycomb: Record finish step"
88-
if: ${{ always() }}
89-
run: |
90-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Finished auto release workflow'
7+
release_prep:
8+
name: "Release Prep"
9+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main"
10+
secrets: "inherit"

.github/workflows/integration_test.yml renamed to .github/workflows/ci.yml

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,28 @@
1-
name: "Integration Testing"
1+
name: "ci"
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
branches:
6+
- "main"
7+
workflow_dispatch:
48

59
env:
610
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
711
HONEYCOMB_DATASET: litmus tests
812

913
jobs:
10-
setup_matrix:
11-
name: "Setup Test Matrix"
12-
runs-on: ubuntu-20.04
13-
outputs:
14-
matrix: ${{ steps.get-matrix.outputs.matrix }}
15-
16-
steps:
17-
- name: "Honeycomb: Start recording"
18-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
19-
with:
20-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
21-
dataset: ${{ env.HONEYCOMB_DATASET }}
22-
job-status: ${{ job.status }}
23-
24-
- name: "Honeycomb: Start first step"
25-
run: |
26-
echo STEP_ID=setup-environment >> $GITHUB_ENV
27-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
28-
29-
- name: Checkout Source
30-
uses: actions/checkout@v2
31-
if: ${{ github.repository_owner == 'puppetlabs' }}
32-
33-
- name: Activate Ruby 2.7
34-
uses: ruby/setup-ruby@v1
35-
if: ${{ github.repository_owner == 'puppetlabs' }}
36-
with:
37-
ruby-version: "2.7"
38-
bundler-cache: true
39-
40-
- name: Print bundle environment
41-
if: ${{ github.repository_owner == 'puppetlabs' }}
42-
run: |
43-
echo ::group::bundler environment
44-
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
45-
echo ::endgroup::
46-
47-
- name: "Honeycomb: Record Setup Environment time"
48-
if: ${{ github.repository_owner == 'puppetlabs' }}
49-
run: |
50-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
51-
echo STEP_ID=Setup-Integration-Test-Matrix >> $GITHUB_ENV
52-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
53-
54-
- name: Setup Integration Test Matrix
55-
id: get-matrix
56-
run: |
57-
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
58-
echo "::set-output name=matrix::{'platform':['centos-7'],'collection':['puppet6-nightly', 'puppet7-nightly']}"
59-
else
60-
echo "::set-output name=matrix::{}"
61-
fi
62-
63-
- name: "Honeycomb: Record Setup Test Matrix time"
64-
if: ${{ always() }}
65-
run: |
66-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
14+
Spec:
15+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
16+
secrets: "inherit"
6717

6818
Integration:
69-
needs:
70-
- setup_matrix
19+
needs: "Spec"
7120
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
7221

7322
runs-on: ubuntu-20.04
7423
strategy:
7524
fail-fast: false
76-
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
25+
matrix: {'platform':['centos-7'],'collection':['puppet6-nightly', 'puppet7-nightly']}
7726

7827
env:
7928
BUILDEVENT_FILE: '../buildevents.txt'

.github/workflows/nightly.yml

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,18 @@ env:
99
HONEYCOMB_DATASET: litmus tests
1010

1111
jobs:
12-
setup_matrix:
13-
name: "Setup Test Matrix"
14-
runs-on: ubuntu-20.04
15-
outputs:
16-
matrix: ${{ steps.get-matrix.outputs.matrix }}
17-
18-
steps:
19-
- name: "Honeycomb: Start recording"
20-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
21-
with:
22-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
23-
dataset: ${{ env.HONEYCOMB_DATASET }}
24-
job-status: ${{ job.status }}
25-
26-
- name: "Honeycomb: Start first step"
27-
run: |
28-
echo STEP_ID=setup-environment >> $GITHUB_ENV
29-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30-
31-
- name: Checkout Source
32-
uses: actions/checkout@v2
33-
if: ${{ github.repository_owner == 'puppetlabs' }}
34-
35-
- name: Activate Ruby 2.7
36-
uses: ruby/setup-ruby@v1
37-
if: ${{ github.repository_owner == 'puppetlabs' }}
38-
with:
39-
ruby-version: "2.7"
40-
bundler-cache: true
41-
42-
- name: Print bundle environment
43-
if: ${{ github.repository_owner == 'puppetlabs' }}
44-
run: |
45-
echo ::group::bundler environment
46-
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
47-
echo ::endgroup::
48-
49-
- name: "Honeycomb: Record Setup Environment time"
50-
if: ${{ github.repository_owner == 'puppetlabs' }}
51-
run: |
52-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
53-
echo STEP_ID=Setup-Integration-Test-Matrix >> $GITHUB_ENV
54-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
55-
56-
- name: Setup Integration Test Matrix
57-
id: get-matrix
58-
run: |
59-
if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then
60-
echo "::set-output name=matrix::{'platform':['centos-7'],'collection':['puppet6-nightly', 'puppet7-nightly']}"
61-
else
62-
echo "::set-output name=matrix::{}"
63-
fi
64-
65-
- name: "Honeycomb: Record Setup Test Matrix time"
66-
if: ${{ always() }}
67-
run: |
68-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
12+
Spec:
13+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
14+
secrets: "inherit"
6915

7016
Integration:
71-
needs:
72-
- setup_matrix
17+
needs: "Spec"
7318
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
7419

7520
runs-on: ubuntu-20.04
7621
strategy:
7722
fail-fast: false
78-
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
23+
matrix: {'platform':['centos-7'],'collection':['puppet6-nightly', 'puppet7-nightly']}
7924

8025
env:
8126
BUILDEVENT_FILE: '../buildevents.txt'
@@ -186,20 +131,3 @@ jobs:
186131
if: ${{ always() }}
187132
run: |
188133
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'
189-
190-
slack-workflow-status:
191-
if: always()
192-
name: Post Workflow Status To Slack
193-
needs:
194-
- Integration
195-
runs-on: ubuntu-20.04
196-
steps:
197-
- name: Slack Workflow Notification
198-
uses: puppetlabs/Gamesight-slack-workflow-status@pdk-templates-v1
199-
with:
200-
# Required Input
201-
repo_token: ${{ secrets.GITHUB_TOKEN }}
202-
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }}
203-
# Optional Input
204-
channel: '#team-cat-bots'
205-
name: 'GABot'

.github/workflows/release.yml

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,7 @@ on:
44
workflow_dispatch:
55

66
jobs:
7-
create-github-release:
8-
name: Deploy GitHub Release
9-
runs-on: ubuntu-20.04
10-
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v2
13-
with:
14-
ref: ${{ github.ref }}
15-
clean: true
16-
fetch-depth: 0
17-
- name: Get Version
18-
id: gv
19-
run: |
20-
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
21-
- name: Create Release
22-
uses: actions/create-release@v1
23-
id: create_release
24-
env:
25-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26-
with:
27-
tag_name: "v${{ steps.gv.outputs.ver }}"
28-
draft: false
29-
prerelease: false
30-
31-
deploy-forge:
32-
name: Deploy to Forge
33-
runs-on: ubuntu-20.04
34-
steps:
35-
- name: Checkout code
36-
uses: actions/checkout@v2
37-
with:
38-
ref: ${{ github.ref }}
39-
clean: true
40-
- name: "PDK Build"
41-
uses: docker://puppet/pdk:nightly
42-
with:
43-
args: 'build'
44-
- name: "Push to Forge"
45-
uses: docker://puppet/pdk:nightly
46-
with:
47-
args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'
7+
release:
8+
name: "Release"
9+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main"
10+
secrets: "inherit"

0 commit comments

Comments
 (0)