Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert repo, user and branch to param-case #184

Closed
wants to merge 17 commits into from
Next Next commit
fix: slugify repo and branch
Josh Barr committed Jun 15, 2022
commit b4065540f8dce1351b6a485e0932a887173acd86
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See https://prettier.io/docs/en/configuration.html#editorconfig

# Stop the editor from looking for .editorconfig files in the parent directories
root = true

[*]
charset = utf-8
insert_final_newline = false
indent_style = tab
indent_size = 2
max_line_length = 100
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@betahuhn/config').eslint
module.exports = require('@betahuhn/config').eslint
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src
dist
.github
*.js
*.yml
*.md
*.json
761 changes: 753 additions & 8 deletions dist/index.js

Large diffs are not rendered by default.

301 changes: 301 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
"@actions/exec": "^1.1.1",
"@actions/github": "^4.0.0",
"action-input-parser": "^1.2.34",
"change-case": "^4.1.2",
"dotenv": "^9.0.2",
"got": "^11.8.3",
"vercel": "^22.0.1"
8 changes: 6 additions & 2 deletions src/github.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,9 @@ const {
} = require('./config')

const init = () => {
const client = github.getOctokit(GITHUB_TOKEN, { previews: [ 'flash', 'ant-man' ] })
const client = github.getOctokit(GITHUB_TOKEN, {
previews: [ 'flash', 'ant-man' ]
})

let deploymentId

@@ -58,7 +60,9 @@ const init = () => {

if (data.length < 1) return

const comment = data.find((comment) => comment.body.includes('This pull request has been deployed to Vercel.'))
const comment = data.find((comment) =>
comment.body.includes('This pull request has been deployed to Vercel.')
)
if (comment) {
await client.issues.deleteComment({
owner: USER,
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ const core = require('@actions/core')
const Github = require('./github')
const Vercel = require('./vercel')
const { addSchema } = require('./helpers')
const { paramCase } = require('change-case')

const {
GITHUB_DEPLOYMENT,
@@ -68,10 +69,9 @@ const run = async () => {
if (IS_PR && PR_PREVIEW_DOMAIN) {
core.info(`Assigning custom preview domain to PR`)

const alias = PR_PREVIEW_DOMAIN
.replace('{USER}', USER)
.replace('{REPO}', REPOSITORY)
.replace('{BRANCH}', BRANCH)
const alias = PR_PREVIEW_DOMAIN.replace('{USER}', USER)
.replace('{REPO}', paramCase(REPOSITORY))
.replace('{BRANCH}', paramCase(BRANCH))
.replace('{PR}', PR_NUMBER)
.replace('{SHA}', SHA.substring(0, 7))
.toLowerCase()
@@ -87,8 +87,8 @@ const run = async () => {
for (let i = 0; i < ALIAS_DOMAINS.length; i++) {
const alias = ALIAS_DOMAINS[i]
.replace('{USER}', USER)
.replace('{REPO}', REPOSITORY)
.replace('{BRANCH}', BRANCH)
.replace('{REPO}', paramCase(REPOSITORY))
.replace('{BRANCH}', paramCase(BRANCH))
.replace('{SHA}', SHA.substring(0, 7))
.toLowerCase()