Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src/main.ts
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2019-12-03 10:28:59 -0500
committerGitHub <noreply@github.com>2019-12-03 10:28:59 -0500
commite404ba5989baa550f631fb1262539d1375a856b7 (patch)
tree4cc911589e7c9a4c976bc99eb4dcb886d2b2d8a8 /src/main.ts
parent6a11491f2eea6739d1296d604c5402cffa43a1f1 (diff)
Convert checkout to a regular action (#70)
Diffstat (limited to 'src/main.ts')
-rw-r--r--src/main.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main.ts b/src/main.ts
new file mode 100644
index 0000000..26da3aa
--- /dev/null
+++ b/src/main.ts
@@ -0,0 +1,47 @@
+import * as core from '@actions/core'
+import * as coreCommand from '@actions/core/lib/command'
+import * as gitSourceProvider from './git-source-provider'
+import * as inputHelper from './input-helper'
+import * as path from 'path'
+
+const cleanupRepositoryPath = process.env['STATE_repositoryPath'] as string
+
+async function run(): Promise<void> {
+ try {
+ const sourceSettings = inputHelper.getInputs()
+
+ try {
+ // Register problem matcher
+ coreCommand.issueCommand(
+ 'add-matcher',
+ {},
+ path.join(__dirname, 'problem-matcher.json')
+ )
+
+ // Get sources
+ await gitSourceProvider.getSource(sourceSettings)
+ } finally {
+ // Unregister problem matcher
+ coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
+ }
+ } catch (error) {
+ core.setFailed(error.message)
+ }
+}
+
+async function cleanup(): Promise<void> {
+ try {
+ await gitSourceProvider.cleanup(cleanupRepositoryPath)
+ } catch (error) {
+ core.warning(error.message)
+ }
+}
+
+// Main
+if (!cleanupRepositoryPath) {
+ run()
+}
+// Post
+else {
+ cleanup()
+}