Skip to content

Commit

Permalink
test: custom action
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jun 12, 2024
1 parent 85ca1eb commit 58cfd40
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test Custom Action

on:
#push to any branch
push:
branches:
- '*'

jobs:
test-action:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Install action
uses: vechain/[email protected]

15 changes: 15 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Setup network-hub CLI'
description: 'Set up the network-hub CLI for use in actions by downloading the latest version from GitHub Releases.'
author: 'VeChain'
inputs:
version:
description: 'The version of the network-hub CLI to install.'
required: true
default: 'latest'
token:
description: 'The GitHub token to use for downloading the network-hub CLI.'
required: true
runs:
using: 'node20'
main: 'action/index.js'
post-if: success()
42 changes: 42 additions & 0 deletions action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const core = require('@actions/core');
const tc = require('@actions/tool-cache');

/**
* Get the download URL for the tool to be installed
* @param {string} version - The version of the tool to be installed
* @returns {Promise<string>}
*/
async function getDownloadURL(version) {
// Get the platform (i.e. linux, darwin, win32)
const platform = process.platform;
// Get the architecture (i.e. x64, arm64)
const arch = process.arch;

console.log(`Platform: ${platform}, Arch: ${arch}`);

const url = `https://github.com/vechain/networkhub/releases/download/${version}/networkHub-${platform}-${arch}${platform === 'win32' ? '.exe' : ''}`;

console.log(`Download URL: ${url}`);

return url;
}

async function setup() {
// Get version of tool to be installed
const version = core.getInput('version');
if (!tc.isExplicitVersion(version)) {
core.setFailed('No version specified')
return
}

// Download the specific version of the tool, e.g. as a tarball
const pathToTarball = await tc.downloadTool(await getDownloadURL(version));

// Extract the tarball onto the runner
const pathToCLI = await tc.extractTar(pathToTarball);

// Expose the tool by adding it to the PATH
core.addPath(pathToCLI)
}

module.exports = setup
75 changes: 75 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@actions/core@^1.10.1", "@actions/core@^1.2.6":
version "1.10.1"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a"
integrity sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==
dependencies:
"@actions/http-client" "^2.0.1"
uuid "^8.3.2"

"@actions/exec@^1.0.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.1.1.tgz#2e43f28c54022537172819a7cf886c844221a611"
integrity sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==
dependencies:
"@actions/io" "^1.0.1"

"@actions/http-client@^2.0.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.2.1.tgz#ed3fe7a5a6d317ac1d39886b0bb999ded229bb38"
integrity sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==
dependencies:
tunnel "^0.0.6"
undici "^5.25.4"

"@actions/io@^1.0.1", "@actions/io@^1.1.1":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.1.3.tgz#4cdb6254da7962b07473ff5c335f3da485d94d71"
integrity sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==

"@actions/tool-cache@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-2.0.1.tgz#8a649b9c07838d9d750c9864814e66a7660ab720"
integrity sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==
dependencies:
"@actions/core" "^1.2.6"
"@actions/exec" "^1.0.0"
"@actions/http-client" "^2.0.1"
"@actions/io" "^1.1.1"
semver "^6.1.0"
uuid "^3.3.2"

"@fastify/busboy@^2.0.0":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d"
integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==

semver@^6.1.0:
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

tunnel@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

undici@^5.25.4:
version "5.28.4"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068"
integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==
dependencies:
"@fastify/busboy" "^2.0.0"

uuid@^3.3.2:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

0 comments on commit 58cfd40

Please sign in to comment.