Skip to content

Commit 6f00837

Browse files
committed
Update README
1 parent e113a0b commit 6f00837

File tree

2 files changed

+86
-75
lines changed

2 files changed

+86
-75
lines changed

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
The MIT License (MIT)
32

43
Copyright (c) 2018 GitHub, Inc. and contributors
@@ -19,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1918
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2019
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2120
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
THE SOFTWARE.
21+
THE SOFTWARE.

README.md

Lines changed: 85 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,117 @@
11
<p align="center">
2-
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
2+
<a href="https://github.com/rubygems/configure-rubygems-credentials/actions">
3+
<img alt="configure-rubygems-credentials-action status" src="https://github.com/rubygems/configure-rubygems-credentials/workflows/build-test/badge.svg">
4+
</a>
35
</p>
46

5-
# Create a JavaScript Action using TypeScript
7+
## Configure RubyGems Credentials for GitHub Actions
68

7-
Use this template to bootstrap the creation of a TypeScript action.:rocket:
9+
Configure your RubyGems credentials and for use in other
10+
GitHub Actions. This action implements OIDC support, writes gem credentials files,
11+
and exports environment variables used by both `rubygems` and
12+
`bundler` for your other Actions to use.
813

9-
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
14+
### Table of Contents
1015

11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
16+
<!-- toc -->
1217

13-
## Create an action from this template
18+
- [Usage](#usage)
19+
- [Examples](#examples)
20+
- [OIDC (recommended)](#oidc-recommended)
21+
- [Static API token in repository secrets](#static-api-token-in-repository-secrets)
22+
- [Use with the RubyGems CLI](#use-with-the-rubygems-cli)
23+
- [License Summary](#license-summary)
24+
- [Security Disclosures](#security-disclosures)
1425

15-
Click the `Use this Template` and provide the new repo details for your action
26+
<!-- tocstop -->
1627

17-
## Code in Main
28+
## Usage
1829

19-
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
30+
We recommend that
31+
you use GitHub's OIDC provider in conjunction with a configured
32+
RubyGems OIDC API Key Role.
2033

21-
Install the dependencies
22-
```bash
23-
$ npm install
24-
```
34+
To do that, you would add the following step to your workflow:
2535

26-
Build the typescript and package it for distribution
27-
```bash
28-
$ npm run build && npm run package
36+
```yaml
37+
- name: Configure RubyGems Credentials
38+
uses: rubygems/configure-rubygems-credentials@main
39+
with:
40+
role-to-assume: 3
2941
```
3042
31-
Run the tests :heavy_check_mark:
32-
```bash
33-
$ npm test
43+
You can use this action with the `rubygems` or `bundler` command line tools,
44+
or run this action multiple times
45+
to use different RubyGems.org accounts or OIDC API Key roles in the same GitHub Actions
46+
workflow. As an example, here is a complete workflow file that pushes a gem release.
3447

35-
PASS ./index.test.js
36-
✓ throws invalid number (3ms)
37-
wait 500 ms (504ms)
38-
test runs (95ms)
39-
40-
...
48+
```yaml
49+
on:
50+
- push
51+
52+
jobs:
53+
job:
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: write
57+
id-token: write
58+
steps:
59+
- uses: rubygems/configure-rubygems-credentials@main
60+
with:
61+
role-to-assume: 2
62+
gem-server: 'https://oidc-api-token.rubygems.org'
63+
audience: 'https://oidc-api-token.rubygems.org'
64+
- uses: actions/checkout@v3
65+
- name: Set remote URL
66+
run: |
67+
git config --global user.email "$(git log -1 --pretty=format:'%ae')"
68+
git config --global user.name "$(git log -1 --pretty=format:'%an')"
69+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
70+
- name: Set up Ruby
71+
uses: ruby/setup-ruby@v1
72+
with:
73+
ruby-version: '3.2.1'
74+
bundler-cache: true
75+
- name: Release
76+
run: bundle exec rake release
4177
```
4278

43-
## Change action.yml
44-
45-
The action.yml defines the inputs and output for your action.
46-
47-
Update the action.yml with your name, description, inputs and outputs for your action.
48-
49-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
50-
51-
## Change the Code
79+
See [action.yml](action.yml) for the full documentation for this action's inputs
80+
and outputs.
5281

53-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
82+
### Examples
5483

55-
```javascript
56-
import * as core from '@actions/core';
57-
...
84+
#### OIDC (recommended)
5885

59-
async function run() {
60-
try {
61-
...
62-
}
63-
catch (error) {
64-
core.setFailed(error.message);
65-
}
66-
}
67-
68-
run()
86+
```yaml
87+
- name: Configure RubyGems Credentials
88+
uses: rubygems/configure-rubygems-credentials@main
89+
with:
90+
role-to-assume: 3
6991
```
7092

71-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
93+
In this example, the Action will load the OIDC token from the GitHub-provided environment variable and use it to assume the role `3`.
7294

73-
## Publish to a distribution branch
95+
#### Static API token in repository secrets
7496

75-
Actions are run from GitHub repos so we will checkin the packed dist folder.
76-
77-
Then run [ncc](https://github.com/zeit/ncc) and push the results:
78-
```bash
79-
$ npm run package
80-
$ git add dist
81-
$ git commit -a -m "prod dependencies"
82-
$ git push origin releases/v1
97+
```yaml
98+
- name: Configure RubyGems Credentials
99+
uses: rubygems/configure-rubygems-credentials@main
100+
with:
101+
api-token: ${{ secrets.RUBYGEMS_API_TOKEN }}
83102
```
84103

85-
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.
104+
In this example, the secret `RUBYGEMS_API_TOKEN` contains a string like `rubygems_1a072a969ecdd84bb190c3c218e13e3c6f5d419f3f0f5b22`.
86105

87-
Your action is now published! :rocket:
106+
### Use with the RubyGems CLI
88107

89-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
108+
This workflow does _not_ install the rubygems
109+
into your environment.
90110

91-
## Validate
92-
93-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
94-
95-
```yaml
96-
uses: ./
97-
with:
98-
milliseconds: 1000
99-
```
111+
## License Summary
100112

101-
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
113+
This code is made available under the MIT license.
102114

103-
## Usage:
115+
## Security Disclosures
104116

105-
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action
117+
If you would like to report a potential security issue in this project, please do not create a GitHub issue. Instead, please follow the instructions [here](https://rubygems.org/pages/security) or [email the RubyGems security team](mailto:[email protected]).

0 commit comments

Comments
 (0)