Skip to content

Commit 2b8cb58

Browse files
committed
feat(main): Added "skipUpload" option (#29)
* feat(main): Added "skipUpload" option * feat(README): Added Skip Upload Section
1 parent df753f2 commit 2b8cb58

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CFX provides API keys for this action.
4949
| assetName | string | The asset name to re-upload | This is the name of the asset you want to re-upload. |
5050
| 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) |
5151
| 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/...`. |
52+
| skipUpload | boolean? | Skip the upload and only log in to the portal | This will skip the asset upload to the portal and only go through the login process. Useful in cron jobs to prevent the cookie from getting invalidated due to inactivity |
5253
| maxRetries | number? | The maximum number of retries. (default: 3) | This is the maximum number of times the login will be retried if it fails. |
5354
| chunkSize | number? | How large one chunk is for upload. Default: 2097152 bytes | |
5455

@@ -57,6 +58,27 @@ CFX provides API keys for this action.
5758
> `?` after the type indicates that the parameter is optional. if no assetName
5859
> or assetId is provided, the repository name will be used as assetName.
5960

61+
## Skip Upload
62+
63+
If you haven't uploaded an asset in a long time, the cookie will become invalid
64+
due to inactivity. To prevent this, you can use a cron job to log in to the
65+
portal and refresh the cookie.
66+
67+
```yaml
68+
name: Refresh Cookie
69+
70+
on:
71+
schedule:
72+
- cron: '0 0 * * *'
73+
74+
jobs:
75+
- name: Login to Portal
76+
uses: Tynopia/cfx-portal-upload
77+
with:
78+
cookie: ${{ secrets.FORUM_COOKIE }}
79+
skipUpload: true
80+
```
81+
6082
## How to Contribute
6183

6284
If you want to contribute to this project, you can fork the repository and

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
assetId:
2929
description: 'The asset id to re-upload'
3030
required: false
31+
skipUpload:
32+
description: 'Skip the upload and only go through the login process'
33+
required: false
3134
chunkSize:
3235
description: 'The chunk size to split the file into'
3336
required: false

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

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

dist/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.

src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export async function run(): Promise<void> {
3535

3636
let zipPath = core.getInput('zipPath')
3737
const makeZip = core.getInput('makeZip').toLowerCase() === 'true'
38+
const skipUpload = core.getInput('skipUpload').toLowerCase() === 'true'
3839

3940
const chunkSize = parseInt(core.getInput('chunkSize'))
4041
const maxRetries = parseInt(core.getInput('maxRetries'))
@@ -48,7 +49,8 @@ export async function run(): Promise<void> {
4849
}
4950

5051
// No asset id or name provided, using the repository name
51-
if (!assetId && !assetName) {
52+
// If skipUpload is true, we don't need to update the asset name
53+
if (!assetId && !assetName && !skipUpload) {
5254
core.debug('No asset id or name provided, using repository name...')
5355
assetName = basename(getEnv('GITHUB_WORKSPACE'))
5456
}
@@ -61,6 +63,11 @@ export async function run(): Promise<void> {
6163
})
6264

6365
if (page.url().includes('portal.cfx.re')) {
66+
if (skipUpload) {
67+
core.info('Redirected to CFX Portal. Skipping upload ...')
68+
return
69+
}
70+
6471
core.info('Redirected to CFX Portal. Uploading file ...')
6572
const cookies = await getCookies(browser)
6673

0 commit comments

Comments
 (0)