Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
be8432c7dd | |||
c084c40288 | |||
13b99645d3 | |||
7805cb3e4c | |||
4482ee6fdc | |||
1414306012 |
31
.github/workflows/test.yaml
vendored
Normal file
31
.github/workflows/test.yaml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-action:
|
||||||
|
runs-on: nix
|
||||||
|
name: Upload and download test
|
||||||
|
steps:
|
||||||
|
- name: Create sample file
|
||||||
|
run: echo "Hello, world!" > test.txt
|
||||||
|
- name: Upload to lgoad
|
||||||
|
id: upload
|
||||||
|
uses: https://git.colon-three.com/kodi/lgoad-upload-action@main
|
||||||
|
with:
|
||||||
|
file: test.txt
|
||||||
|
token: ${{ secrets.LGOAD_TOKEN }}
|
||||||
|
custom-machine-name: 'github-action-test-machine'
|
||||||
|
content-type: 'text/plain'
|
||||||
|
custom-name: 'test.txt'
|
||||||
|
use-salt: 'true'
|
||||||
|
- name: Print the URL
|
||||||
|
run: echo "The URL is ${{ steps.upload.outputs.url }}"
|
||||||
|
- name: Check that the file is correctly uploaded
|
||||||
|
run: |
|
||||||
|
curl -s -o test-uploaded.txt ${{ steps.upload.outputs.url }}
|
||||||
|
nix shell "nixpkgs#diffutils" -c diff test.txt test-uploaded.txt
|
||||||
|
rm test.txt
|
||||||
|
|
10
index.js
10
index.js
@ -10,10 +10,12 @@ try {
|
|||||||
const file = core.getInput('file')
|
const file = core.getInput('file')
|
||||||
if (!file) {
|
if (!file) {
|
||||||
core.setFailed('"file" is required')
|
core.setFailed('"file" is required')
|
||||||
|
process.exit(1)
|
||||||
}
|
}
|
||||||
const token = core.getInput('token')
|
const token = core.getInput('token')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
core.setFailed('"token" is required')
|
core.setFailed('"token" is required')
|
||||||
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const machine_name = core.getInput('custom-machine-name') || os.hostname()
|
const machine_name = core.getInput('custom-machine-name') || os.hostname()
|
||||||
@ -40,7 +42,13 @@ try {
|
|||||||
'x-salt-name': use_salt ? 'true' : 'false',
|
'x-salt-name': use_salt ? 'true' : 'false',
|
||||||
'authorization': `Bearer ${token}`
|
'authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
}).then(response => { return response.text() })
|
}).then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
console.log("Got response: ", response)
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
}
|
||||||
|
return response.text()
|
||||||
|
})
|
||||||
.then(uri => {
|
.then(uri => {
|
||||||
console.log("Uploaded to: ", uri)
|
console.log("Uploaded to: ", uri)
|
||||||
core.setOutput('uri', uri)
|
core.setOutput('uri', uri)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user