From 8023b7d22508f3127a4479608ae809ab330a3c1c Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Wed, 25 Sep 2019 09:14:38 +0900 Subject: [PATCH] Add multi platform action source --- action.yml | 5 +++++ index.js | 25 +++++++++++++++++++++++++ package-lock.json | 18 ++++++++++++++++++ package.json | 22 ++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 action.yml create mode 100644 index.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..4611faa --- /dev/null +++ b/action.yml @@ -0,0 +1,5 @@ +name: 'Create Pull Request' +description: 'Creates a pull request for changes to your repository in the actions workspace' +runs: + using: 'node12' + main: 'index.js' diff --git a/index.js b/index.js new file mode 100644 index 0000000..bc660b9 --- /dev/null +++ b/index.js @@ -0,0 +1,25 @@ +const core = require('@actions/core'); +const exec = require('@actions/exec'); +const os = require('os'); + +async function run() { + try { + core.info(`platform: ${os.platform()}`) + core.info(`action directory: ${__dirname}`) + + if (os.platform() == 'linux') { + await exec.exec('sudo apt-get install python3-setuptools'); + } + await exec.exec(`pip3 install --requirement ${__dirname}/requirements.txt`); + if (os.platform() == 'win32') { + await exec.exec(`python ${__dirname}/create-pull-request.py`); + } else { + await exec.exec(`python3 ${__dirname}/create-pull-request.py`); + } + } + catch (error) { + core.setFailed(error.message); + } +} + +run() diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..5f26660 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,18 @@ +{ + "name": "create-pull-request", + "version": "1.2.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@actions/core": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz", + "integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==" + }, + "@actions/exec": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz", + "integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..10191b0 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "create-pull-request", + "version": "1.2.1", + "description": "Creates a pull request for changes to your repository in the actions workspace", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/peter-evans/create-pull-request.git" + }, + "keywords": [ + "GitHub", + "Actions", + "Pull Request" + ], + "author": "Peter Evans", + "license": "MIT", + "homepage": "https://github.com/peter-evans/create-pull-request", + "dependencies": { + "@actions/core": "^1.1.1", + "@actions/exec": "^1.0.1" + } +}