diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..170330a
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,15 @@
+name: "Tests"
+
+on:
+ pull_request:
+ push:
+ branches: # array of glob patterns matching against refs/heads. Optional; defaults to all
+ - master # triggers on pushes that contain changes in master
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ - run: npm ci
+ - run: npm test
diff --git a/.github/workflows/upload-release-asset.yml b/.github/workflows/upload-release-asset.yml
deleted file mode 100644
index b0cc944..0000000
--- a/.github/workflows/upload-release-asset.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-on:
- push:
- tags:
- - 'v*'
-
-name: Upload Release Asset
-
-jobs:
- build:
- name: Upload Release Asset
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@master
- - name: Build project # This would actually build your project, using zip for an example artifact
- run: |
- zip --junk-paths my-artifact README.md
- - name: Create Release
- id: create_release
- uses: actions/create-release@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag_name: ${{ github.ref }}
- release_name: Release ${{ github.ref }}
- draft: false
- prerelease: false
- - name: Upload Release Asset
- id: upload-release-asset
- uses: actions/upload-release-asset@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./my-artifact.zip
- asset_name: my-artifact.zip
- asset_content_type: application/zip
diff --git a/README.md b/README.md
index a8c0939..7a48e8f 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# GitHub Action - Releases API
This GitHub Action (written in JavaScript) wraps the [GitHub Release API](https://developer.github.com/v3/repos/releases/), specifically the [Upload a Release Asset](https://developer.github.com/v3/repos/releases/#upload-a-release-asset) endpoint, to allow you to leverage GitHub Actions to upload release assets.
-
+
## Usage
### Pre-requisites
diff --git a/tests/main.test.js b/tests/main.test.js
new file mode 100644
index 0000000..9b1e9d4
--- /dev/null
+++ b/tests/main.test.js
@@ -0,0 +1,37 @@
+jest.mock('@actions/github');
+
+const { GitHub, context } = require('@actions/github');
+const run = require('../src/main.js');
+
+/* eslint-disable no-undef */
+describe('module', () => {
+ let uploadReleaseAsset;
+
+ beforeEach(() => {
+ uploadReleaseAsset = jest.fn();
+
+ context.repo = {
+ owner: 'owner',
+ repo: 'repo'
+ };
+
+ const github = {
+ repos: {
+ uploadReleaseAsset
+ }
+ };
+
+ GitHub.mockImplementation(() => github);
+ });
+
+ test('Upload release endpoint is called', async () => {
+ await run();
+
+ expect(uploadReleaseAsset).toHaveBeenCalledWith({
+ owner: 'owner',
+ repo: 'repo'
+ });
+ });
+
+ test('Outputs are set', async () => {});
+});