Skip to content

Commit

Permalink
Typescript (#42)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
peter-murray authored Oct 15, 2024
1 parent baa1ef2 commit c0f4dcf
Show file tree
Hide file tree
Showing 27 changed files with 1,848 additions and 1,260 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"extensions": [
"dbaeumer.vscode-eslint",
"redhat.vscode-yaml",
"swellaby.node-pack"
"swellaby.node-pack",
"vitest.explorer"
],
}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_organization_installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ jobs:
with:
github-token: ${{ steps.use_action.outputs.token }}
script: |
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'demo-bootstrap'});
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'bootstrap'});
console.log(JSON.stringify(repo, null, 2));
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
with:
github-token: ${{ steps.use_action.outputs.token }}
script: |
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'demo-bootstrap'});
const repo = await github.rest.repos.get({owner: 'octodemo', repo: 'bootstrap'});
console.log(JSON.stringify(repo, null, 2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Tests this action success by the application already being installed on the repository

name: Test Success - repository - installed - with proxy - ignored

on:
push:
workflow_dispatch:
inputs:
branch:
description: The name of the branch to checkout for the action
required: true
default: main

jobs:
test:
runs-on: ubuntu-latest

# services:
# squid:
# image: ubuntu/squid
# ports:
# - 3128/tcp
# volumes:
# - '${{ github.workspace }}:/var/log/squid'
# options: --dns 8.8.8.8

steps:
- name: Checkout specified branch
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Checkout
if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v4

- name: Start Squid Proxy container
run: |
mkdir ${{ github.workspace }}/squid
sudo chown proxy:proxy ${{ github.workspace }}/squid
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
sleep 5
docker logs squid
docker inspect squid
curl http://localhost:3128
- name: Use action
id: use_action
continue-on-error: true
uses: ./
env:
HTTPS_PROXY: http://localhost:3128
with:
application_id: ${{ secrets.APPLICATION_ID }}
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
ignore_environment_proxy: true

- name: Show Squid Logs and stop container
run: |
docker stop squid
ls -la ${{ github.workspace }}/squid
echo "Access Logs:"
sudo cat ${{ github.workspace }}/squid/access.log
- name: Use token to read details
uses: actions/github-script@v7
with:
github-token: ${{ steps.use_action.outputs.token }}
script: |
const repo = await github.rest.repos.get(context.repo);
console.log(JSON.stringify(repo, null, 2));
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
*.iml

# Node.js / npm
node_modules
node_modules
lib

# Squid logs
squid
11 changes: 5 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"debug.onTaskErrors": "showErrors",
"files.trimTrailingWhitespace": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": true,
"editor.detectIndentation": false,
"[javascript]": {
"editor.tabSize": 2
},
"[jsonc]": {
"editor.tabSize": 2,
},
"[json]": {
"editor.tabSize": 2
"editor.tabSize": 2,
},
"[yaml]": {
"editor.tabSize": 2
}
}
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
required: true

permissions:
description: "The permissions to request e.g. issues:read,secrets:write,packages:read. Defaults to all available permissions"
description: The permissions to request e.g. issues:read,secrets:write,packages:read. Defaults to all available permissions
required: false

organization:
Expand All @@ -29,6 +29,11 @@ inputs:
description: Option proxy server for making the requests
required: false

ignore_environment_proxy:
description: Optional flag to forcibly ignore the proxy server setting in the environment
required: false
default: 'false'

revoke_token:
description: Flag to revoke the token after the job is complete, defaults to 'false', set to 'true' to revoke in the post job processing.
required: false
Expand Down
10 changes: 6 additions & 4 deletions dist/main/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/main/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
1 change: 1 addition & 0 deletions dist/main/sourcemap-register.cjs

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions dist/post/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/post/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
1 change: 1 addition & 0 deletions dist/post/sourcemap-register.cjs

Large diffs are not rendered by default.

Loading

0 comments on commit c0f4dcf

Please sign in to comment.