Skip to content

Commit

Permalink
Merge pull request #13 from XenoS-ITA/zip-creation-and-assetName
Browse files Browse the repository at this point in the history
Zip creation and asset name
  • Loading branch information
Tynopia authored Feb 15, 2025
2 parents d0908ba + 486ee3c commit 6c42d5b
Show file tree
Hide file tree
Showing 14 changed files with 93,781 additions and 56,528 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
cfx-portal-upload:
name: GitHub Actions Test
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ CFX provides API keys for this action.
1. Navigate to the **Cookies** section and search for `_t`.
1. Copy the value of this cookie and save it in GitHub Secrets as
`FORUM_COOKIE`.
1. Use the action in your workflow:
1. Use the action in your workflow (remember to
[checkout](https://github.com/actions/checkout) before!):

```yaml
- name: Upload Escrow Resource
uses: Tynopia/cfx-portal-upload
with:
cookie: ${{ secrets.FORUM_COOKIE }}
zipPath: /path/to/your/zip
assetId: 489345
assetName: 'my_asset'
```
1. Additionally, you can configure the `chunkSize` option.

> [!IMPORTANT]
>
> When you log out of the forum, the cookie will become invalid, causing the
Expand All @@ -44,12 +42,20 @@ CFX provides API keys for this action.
## Input Parameters
| Key | Value | How to get it |
| -------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| cookie | The Forum Cookie to authenticate | Go to [forum.cfx.re](https://forum.cfx.re) and inspect the page with your browser's dev tools. Then search for the `_t` cookie. |
| zipPath | The path to your ZIP file that should be uploaded | This is the file location of your packed ZIP file inside the Workflow Container, usually stored in `/home/...`. |
| assetId | The Asset ID, which is a unique ID in the portal | The Asset ID can be found at [portal.cfx.re](https://portal.cfx.re/assets/created-assets). ![image](https://github.com/user-attachments/assets/4176b7e7-cfbb-4e14-a488-04c4301f6082) |
| chunkSize (Optional) | How large one chunk is for upload. Default: 2097152 bytes | |
| Key | Type | Value | Description |
| ---------- | -------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| cookie | string | The Forum Cookie to authenticate | Go to [forum.cfx.re](https://forum.cfx.re) and inspect the page with your browser's dev tools. Then search for the `_t` cookie. |
| makeZip | boolean? | Automatically ZIP the full repository to upload it (default: true) | This will remove the folders `.git/`/`.github/`/`.vscode/` from the repository before zipping. |
| assetName | string | The asset name to re-upload | This is the name of the asset you want to re-upload. |
| assetId | number | The Asset ID, which is a unique ID in the portal | The Asset ID can be found at [portal.cfx.re](https://portal.cfx.re/assets/created-assets). ![image](https://github.com/user-attachments/assets/4176b7e7-cfbb-4e14-a488-04c4301f6082) |
| zipPath | string? | The path to your ZIP file that should be uploaded | This is the file location of your packed ZIP file inside the Workflow Container, usually stored in `/home/...`. |
| maxRetries | number? | The maximum number of retries. (default: 3) | This is the maximum number of times the login will be retried if it fails. |
| chunkSize | number? | How large one chunk is for upload. Default: 2097152 bytes | |

> [!NOTE]
>
> `?` after the type indicates that the parameter is optional. if no assetName
> or assetId is provided, the repository name will be used as assetName.

## How to Contribute

Expand Down
5 changes: 5 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ describe('action', () => {
switch (name) {
case 'chunkSize':
return '1024'
case 'makeZip':
return 'true'
case 'maxRetries':
return '1'
case 'cookie':
case 'assetId':
case 'assetName':
case 'zipPath':
return 'test-value'
default:
Expand Down
18 changes: 15 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ inputs:
cookie:
description: 'Your Forum Account Cookie'
required: true
makeZip:
description:
'Automatically zip the full repository to upload it (true or false)'
required: false
default: true
assetName:
description: 'The asset name to re-upload'
required: false
maxRetries:
description: 'The maximum number of retries'
required: false
default: 3
zipPath:
description: 'The path to the zip file to upload'
required: true
required: false
assetId:
description: 'The asset id to re-upload'
required: true
required: false
chunkSize:
description: 'The chunk size to split the file into'
required: true
required: false
default: 2097152

runs:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6c42d5b

Please sign in to comment.