Skip to content

LCBC-UiO/tsd-import-action

Repository files navigation

TSD Import Action

This GitHub Action uploads a single file using a TSD (Services for Sensitive Data) link UUID and secret phrase.

Setup

  1. Create an import link at: https://selfservice.tsd.usit.no/import-links
    You must check "secret", and specifying a PATH on the server is advised.

  2. Set secrets in your github repository:

  • SECRET_UUID - The upload link/instance UUID
  • SECRET_PHRASE - The secret phrase for authentication
    Hint: Settings > Security > Secrets and variables > Actions

Inputs

  • FILE (required) - Path to the SINGLE file that will be uploaded to the root of the path provided when setting up the import link

Outputs

  • status_code - HTTP status code from the upload response

Example Usage

on:
  push:
    branches: [main]

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Upload file to TSD
        uses: LCBC-UIO/tsd-import-action@v2.0.1
        env:
          SECRET_UUID: ${{ secrets.SECRET_UUID }}
          SECRET_PHRASE: ${{ secrets.SECRET_PHRASE }}
        with:
          FILE: README.md

Make sure to run the upload action only on events that you (or another trusted collaborator) controls, i.e. do not run the import action on any PR as that could allow someone to accidentally or intentioonally overwrite your files. The example above (on push to main) runs the action only when commits are pushed to main (directly or when a PR is merged), not when PRs are opened from other branches/forks.

Development

This action is built with TypeScript and requires Node.js 20.

Setup Development Environment

npm install

Build the Action

npm run build

This compiles the TypeScript code and bundles it with all dependencies into a single dist/index.js file using @vercel/ncc.

Run Tests

npm test

Linting and Formatting

npm run lint
npm run format

Run All Checks

npm run all

This runs formatting, linting, tests, and builds the action.

Important Notes

  • The dist/ folder must be committed to the repository for the GitHub Action to work
  • Always run npm run build after making changes to the TypeScript source code
  • The action uses Node.js 20

Migration from v0/1 to v2

Version 2.0 represents a rewrite from Python/Docker to TypeScript/Node.js:

  • Faster: No Docker container overhead means quicker startup times
  • Same API: All inputs and environment variables remain the same
  • New output: Now provides status_code output with the HTTP response code

If you need the Python/Docker version, use @v0.2 in your workflow.

Acknowledgements

This project was inspired by https://github.com/unioslo/vscode-tsd-sync

About

Auto push your builds to TSD in CI

Resources

License

Stars

Watchers

Forks

Contributors