Skip to content

Commit a52d224

Browse files
Revert "Merge pull request #130 from puppetlabs/OSPTE-186"
This reverts commit 03d8a7d, reversing changes made to 28ec60f.
1 parent 03d8a7d commit a52d224

File tree

5 files changed

+115
-99
lines changed

5 files changed

+115
-99
lines changed

.github/workflows/gem_ci.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,15 @@ on:
3030
default: false
3131
type: "boolean"
3232

33-
# ENABLE PUPPETCORE. The calling workflow must:
34-
# - Set a valid PUPPET_FORGE_TOKEN secret on its repository.
35-
# - Set ruby_version >= 3.1 to override this workflow's default 2.7; otherwise bundle install will fail.
36-
env:
37-
PUPPET_GEM_VERSION: ${{ inputs.puppet_gem_version }}
38-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39-
PUPPET_FORGE_TOKEN: ${{ secrets.PUPPET_FORGE_TOKEN }}
40-
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN }}"
41-
4233
jobs:
4334
spec:
4435
name: "spec"
4536
runs-on: ${{ inputs.runs_on }}
4637

38+
env:
39+
PUPPET_GEM_VERSION: ${{ inputs.puppet_gem_version }}
40+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
41+
4742
steps:
4843
- name: "checkout"
4944
uses: "actions/checkout@v4"

.github/workflows/module_ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ on:
2424
required: false
2525
default: '3.1'
2626
type: "string"
27+
puppetcore_api_type:
28+
description: "The type of API to use for Puppet Core."
29+
required: false
30+
default: 'forge-key'
31+
type: "string"
2732

2833
# ENABLE PUPPETCORE. The calling workflow must:
2934
# - Set a valid PUPPET_FORGE_TOKEN secret on its repository.
3035
# - Set ruby_version >= 3.1 to override this workflow's default 2.7; otherwise bundle install will fail.
3136
env:
3237
PUPPET_FORGE_TOKEN: ${{ secrets.PUPPET_FORGE_TOKEN }}
33-
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN }}"
38+
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "${{ inputs.puppetcore_api_type }}:${{ secrets.PUPPET_FORGE_TOKEN }}"
3439

3540
jobs:
3641
setup_matrix:

.github/workflows/tooling_mend_ruby.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ env:
2525
MEND_TOKEN: ${{ secrets.MEND_TOKEN != '' && secrets.MEND_TOKEN || inputs.token }}
2626
PRODUCT_NAME: ${{ inputs.PRODUCT_NAME != '' && inputs.PRODUCT_NAME || inputs.product_name }}
2727
REQUIRE_SECRETS: MEND_API_KEY MEND_TOKEN
28-
# ENABLE PUPPETCORE. The calling workflow must:
29-
# - Set a valid PUPPET_FORGE_TOKEN secret on its repository.
30-
# - Set ruby_version >= 3.1 to override this workflow's default 2.7; otherwise bundle install will fail.
31-
PUPPET_FORGE_TOKEN: ${{ secrets.PUPPET_FORGE_TOKEN }}
32-
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN }}"
3328

3429
jobs:
3530
mend:

docs/how-to/how_to_inject_puppetcore_authentication_into_the_shared_workflows.md

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# How to use the module_ci workflow with puppetcore gems
2+
3+
## Description
4+
5+
This guide explains how to configure your repository to use the shared `module_ci.yml` workflow with PuppetCore Gems. The workflow is designed to maintain backward compatibility with existing consumers (like puppetlabs-apache and puppetlabs-ntp) while providing the capability to install and use gems from the private PuppetCore gem source.
6+
7+
## Prerequisites
8+
9+
- A GitHub repository that needs to use the `module_ci.yml` workflow
10+
- Access to repository settings to configure secrets
11+
- A valid `PUPPET_FORGE_TOKEN` with access to the private gem source
12+
13+
## Configuration Requirements
14+
15+
### Required Settings
16+
17+
To use PuppetCore Gems with the module_ci workflow, your repository must meet these requirements:
18+
19+
1. **Set up the PUPPET_FORGE_TOKEN secret**:
20+
- Navigate to your repository on GitHub
21+
- Go to Settings > Secrets and variables > Actions
22+
- Add a new repository secret named `PUPPET_FORGE_TOKEN` with your valid token value
23+
24+
2. **Configure Ruby Version**:
25+
- Must specify a Ruby version >= 3.1 (required for PuppetCore Gems)
26+
- The default Ruby version in module_ci.yml is 2.7 and must be overridden
27+
28+
### Optional Settings
29+
30+
- **PuppetCore API Type**:
31+
- By default, set to 'forge-key'
32+
- Can be changed to 'license-key' if required
33+
34+
## Usage
35+
36+
Create or update your workflow file (typically `.github/workflows/ci.yml`) to look something like:
37+
38+
```yaml
39+
name: "ci"
40+
41+
on:
42+
pull_request:
43+
branches:
44+
- "main"
45+
workflow_dispatch:
46+
47+
jobs:
48+
Spec:
49+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
50+
with:
51+
run_shellcheck: true
52+
ruby_version: '3.1' # Required for PuppetCore Gems
53+
secrets: "inherit" # Required to pass PUPPET_FORGE_TOKEN
54+
```
55+
56+
## How It Works
57+
58+
When properly configured, the `module_ci.yml` workflow will:
59+
60+
1. Inherit the `PUPPET_FORGE_TOKEN` secret from the consumer repository.
61+
2. Set the following `BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM` environment variable ensuring authentication against the <https://rubygems-puppetcore.puppet.com> gemsource, e.g,:
62+
63+
```shell
64+
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN }}"
65+
```
66+
67+
3. Install gems from <https://rubygems-puppetcore.puppet.com>.
68+
69+
## Troubleshooting
70+
71+
Common issues and their solutions:
72+
73+
- **Bundle install fails**: Ensure Ruby version is set to at least 3.1
74+
- **Authentication errors**: Verify the PUPPET_FORGE_TOKEN is correctly set and has appropriate permissions
75+
76+
## Appendix
77+
78+
### Sample Implementation
79+
80+
Example configuration in a consuming repository:
81+
82+
```yaml
83+
name: "ci"
84+
85+
on:
86+
pull_request:
87+
branches:
88+
- "main"
89+
workflow_dispatch:
90+
91+
jobs:
92+
Spec:
93+
uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main"
94+
with:
95+
run_shellcheck: true
96+
ruby_version: '3.1'
97+
puppetcore_api_type: 'license-key'
98+
secrets: "inherit"
99+
```
100+
101+
### Security Considerations
102+
103+
- Never hardcode the PUPPET_FORGE_TOKEN in your workflow files
104+
- Use the `secrets: "inherit"` pattern to securely pass tokens
105+
- Regularly rotate your tokens following security best practices

0 commit comments

Comments
 (0)