Skip to content

Commit

Permalink
add basic clean-pr-env action
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshanziya committed Jun 4, 2024
1 parent 7d6fbc1 commit 4c5e1bc
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
id: test-action
uses: ./
with:
action: 'deploy'
action: 'clean-pr-env'
project-id: 'abc'
cli-token: ${{ secrets.PLATFORMSH_CLI_TOKEN }}
# cli-version: '5.0.9'
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 48 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/clean-pr-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as core from '@actions/core'
export async function cleanPrEnv(): Promise<void> {
core.startGroup('Cleanr PR env from Platform.sh')
core.info('Env cleaned')
core.endGroup()
}
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as core from '@actions/core'
import { deploy } from './deploy'
import { installCli } from './install-cli'
import { cleanPrEnv } from './clean-pr-env'
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
const action = core.getInput('action')
if (!['deploy', 'clean'].includes(action)) {
if (!['deploy', 'clean-pr-env'].includes(action)) {
throw new Error('Invalid action to perform')
}

Expand All @@ -17,7 +18,11 @@ export async function run(): Promise<void> {
// Deploy to platform.sh
if (action === 'deploy') {
await deploy()
return
}

core.info('Inside custom action')
// Clean the env
if (action === 'clean-pr-env') {
await cleanPrEnv()
}
}

0 comments on commit 4c5e1bc

Please sign in to comment.