Skip to content

Commit c0f4dcf

Browse files
authored
Typescript (#42)
Converting the project in to TypeScript and updating the libraries to resolve a number of existing issues with the changes to Octokit and the proxy integration support. Migration to TypeScript: Renamed index.js to src/actions/main.ts and refactored it to use TypeScript, including adding type annotations and updating import statements. Renamed post.js to src/actions/post.ts and refactored it to use TypeScript, including adding type annotations and updating import statements. New GitHub Actions Workflow: Added a new workflow file test_repository_installed_proxy_explict_ignore.yml to test the action with a proxy and ignore settings. Dependency and Configuration Updates: Updated package.json to include TypeScript and Vitest dependencies, and modified scripts to use these tools. Minor Fixes and Enhancements: Updated repository names in test_organization_installed.yml and test_organization_installed_revocation.yml workflow files. Added the ignore_environment_proxy input to the action.yml to allow ignoring proxy settings.
1 parent baa1ef2 commit c0f4dcf

27 files changed

Lines changed: 1848 additions & 1260 deletions

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"extensions": [
88
"dbaeumer.vscode-eslint",
99
"redhat.vscode-yaml",
10-
"swellaby.node-pack"
10+
"swellaby.node-pack",
11+
"vitest.explorer"
1112
],
1213
}
1314
}

.github/workflows/test_organization_installed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ jobs:
3939
with:
4040
github-token: ${{ steps.use_action.outputs.token }}
4141
script: |
42-
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'demo-bootstrap'});
42+
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'bootstrap'});
4343
console.log(JSON.stringify(repo, null, 2));

.github/workflows/test_organization_installed_revocation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
with:
4141
github-token: ${{ steps.use_action.outputs.token }}
4242
script: |
43-
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'demo-bootstrap'});
43+
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'bootstrap'});
4444
console.log(JSON.stringify(repo, null, 2));
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Tests this action success by the application already being installed on the repository
2+
3+
name: Test Success - repository - installed - with proxy - ignored
4+
5+
on:
6+
push:
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: The name of the branch to checkout for the action
11+
required: true
12+
default: main
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
# services:
19+
# squid:
20+
# image: ubuntu/squid
21+
# ports:
22+
# - 3128/tcp
23+
# volumes:
24+
# - '${{ github.workspace }}:/var/log/squid'
25+
# options: --dns 8.8.8.8
26+
27+
steps:
28+
- name: Checkout specified branch
29+
if: github.event_name == 'workflow_dispatch'
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.inputs.branch }}
33+
34+
- name: Checkout
35+
if: github.event_name != 'workflow_dispatch'
36+
uses: actions/checkout@v4
37+
38+
- name: Start Squid Proxy container
39+
run: |
40+
mkdir ${{ github.workspace }}/squid
41+
sudo chown proxy:proxy ${{ github.workspace }}/squid
42+
docker run -dit --name squid -p 3128:3128 -v ${{ github.workspace }}/test/squid.conf:/etc/squid/squid.conf -v ${{ github.workspace }}/squid:/var/log/squid ubuntu/squid:latest
43+
sleep 5
44+
docker logs squid
45+
docker inspect squid
46+
curl http://localhost:3128
47+
48+
- name: Use action
49+
id: use_action
50+
continue-on-error: true
51+
uses: ./
52+
env:
53+
HTTPS_PROXY: http://localhost:3128
54+
with:
55+
application_id: ${{ secrets.APPLICATION_ID }}
56+
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
57+
ignore_environment_proxy: true
58+
59+
- name: Show Squid Logs and stop container
60+
run: |
61+
docker stop squid
62+
ls -la ${{ github.workspace }}/squid
63+
echo "Access Logs:"
64+
sudo cat ${{ github.workspace }}/squid/access.log
65+
66+
- name: Use token to read details
67+
uses: actions/github-script@v7
68+
with:
69+
github-token: ${{ steps.use_action.outputs.token }}
70+
script: |
71+
const repo = await github.rest.repos.get(context.repo);
72+
console.log(JSON.stringify(repo, null, 2));

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
*.iml
44

55
# Node.js / npm
6-
node_modules
6+
node_modules
7+
lib
8+
9+
# Squid logs
10+
squid

.vscode/settings.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
2-
"debug.onTaskErrors": "showErrors",
3-
"files.trimTrailingWhitespace": true,
42
"editor.tabSize": 2,
53
"editor.insertSpaces": true,
4+
"files.trimTrailingWhitespace": true,
65
"editor.detectIndentation": false,
76
"[javascript]": {
87
"editor.tabSize": 2
98
},
9+
"[jsonc]": {
10+
"editor.tabSize": 2,
11+
},
1012
"[json]": {
11-
"editor.tabSize": 2
13+
"editor.tabSize": 2,
1214
},
13-
"[yaml]": {
14-
"editor.tabSize": 2
15-
}
1615
}

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ inputs:
1414
required: true
1515

1616
permissions:
17-
description: "The permissions to request e.g. issues:read,secrets:write,packages:read. Defaults to all available permissions"
17+
description: The permissions to request e.g. issues:read,secrets:write,packages:read. Defaults to all available permissions
1818
required: false
1919

2020
organization:
@@ -29,6 +29,11 @@ inputs:
2929
description: Option proxy server for making the requests
3030
required: false
3131

32+
ignore_environment_proxy:
33+
description: Optional flag to forcibly ignore the proxy server setting in the environment
34+
required: false
35+
default: 'false'
36+
3237
revoke_token:
3338
description: Flag to revoke the token after the job is complete, defaults to 'false', set to 'true' to revoke in the post job processing.
3439
required: false

dist/main/index.js

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

0 commit comments

Comments
 (0)