Skip to content

Commit c6c8efe

Browse files
Initial Commit
0 parents  commit c6c8efe

File tree

5 files changed

+9006
-0
lines changed

5 files changed

+9006
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Continuous Auth GitHub Action
2+
3+
> CFA via Semantic Release in a simple action
4+
5+
## Example
6+
7+
```yaml
8+
name: Publish
9+
10+
on: [push]
11+
12+
permissions:
13+
id-token: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
environment: npm
19+
steps:
20+
# For security please pin this to the SHA of the latest release
21+
# - https://github.com/actions/checkout/releases/latest
22+
- uses: actions/checkout@{sha}
23+
with:
24+
# This is key, ensure that you set this on your checkout
25+
persist-credentials: false
26+
# For security please pin this to the SHA of the latest release
27+
# - https://github.com/continuousauth/action/releases/latest
28+
- uses: continuousauth/action@{sha}
29+
with:
30+
project-id: ${{ secrets.CFA_PROJECT_ID }}
31+
secret: ${{ secrets.CFA_SECRET }}
32+
npm-token: ${{ secrets.NPM_TOKEN }}
33+
34+
35+
```

action.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Continuous Auth Publish Action'
2+
description: 'Publish a semantic release npm package via CFA'
3+
inputs:
4+
project-id:
5+
description: 'CFA_PROJECT_ID secret value'
6+
required: true
7+
secret:
8+
description: 'CFA_SECRET secret value'
9+
required: true
10+
npm-token:
11+
description: 'NPM_TOKEN secret value'
12+
required: true
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Set up publishing environment
17+
run: |
18+
SHA=1775eb1aacafd0266ea1897255758d985d0bf291
19+
DIR=/tmp/semantic-release-packages
20+
mkdir $DIR
21+
cp ${{ github.action_path }}/package.json $DIR/package.json
22+
cp ${{ github.action_path }}/package-lock.json $DIR/package-lock.json
23+
cd $DIR
24+
npm ci
25+
echo "$DIR/node_modules/.bin" >> "$GITHUB_PATH"
26+
shell: bash
27+
28+
- name: Obtain OIDC token
29+
id: oidc
30+
run: |
31+
token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
32+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=continuousauth.dev" | jq -r '.value')
33+
echo "::add-mask::${token}"
34+
echo "token=${token}" >> $GITHUB_OUTPUT
35+
shell: bash
36+
37+
- name: Obtain GitHub credentials
38+
id: github_creds
39+
run: |
40+
token=$(curl --fail "https://continuousauth.dev/api/request/${{ inputs.project-id }}/github/credentials" \
41+
-X POST \
42+
-H "Content-Type: application/json" \
43+
-H "Authorization: bearer ${{ inputs.secret }}" \
44+
--data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN')
45+
echo "::add-mask::${token}"
46+
echo "token=${token}" >> $GITHUB_OUTPUT
47+
shell: bash
48+
49+
- name: Run semantic release
50+
run: semantic-release
51+
shell: bash
52+
env:
53+
GITHUB_ACTION: 1
54+
GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }}
55+
CFA_PROJECT_ID: ${{ inputs.project-id }}
56+
CFA_SECRET: ${{ inputs.secret }}
57+
NPM_TOKEN: ${{ inputs.npm-token }}

0 commit comments

Comments
 (0)