Skip to content

Commit

Permalink
IMPROVE: posting article with the test
Browse files Browse the repository at this point in the history
  • Loading branch information
ommyjay committed Apr 1, 2022
1 parent 70b201e commit 27a812b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 33 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ jobs:
- uses: actions/checkout@v3
- uses: ./
with:
milliseconds: 1000
title: 'Testing cross-release'
body_markdown: '# Test'
tags: 'test'
canonical_url: 'https://github.com/ommyjay/blogs-cross-post-action-for-teams'
published: 'false'
series: 'javascript'
devto_organization_id: ${{ secrets.DEVTO_ORGANIZATION_ID }}
devto_api_key: ${{ secrets.DEVTO_API_KEY }}
2 changes: 1 addition & 1 deletion __tests__/devto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('post to dev.to', async () => {
canonical_url: faker.internet.url(),
published: 'false',
series: faker.random.word(),
organization_id: faker.random.word()
devto_organization_id: faker.random.word()
}
},
config: {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('test runs', () => {
process.env['INPUT_CANONICAL_URL'] = 'something else 🤿'
process.env['INPUT_PUBLISHED'] = 'something else 🤿'
process.env['INPUT_SERIES'] = 'something else 🤿'
process.env['INPUT_ORGANIZATION_ID'] = '0000'
process.env['INPUT_DEVTO_ORGANIZATION_ID'] = '0000'
process.env['INPUT_DEVTO_API_KEY'] = 'somethingelse'
const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
Expand Down
13 changes: 1 addition & 12 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.

2 changes: 1 addition & 1 deletion src/devto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type DevToArticleData = {
canonical_url: string
published: string
series: string
organization_id: string
devto_organization_id: string
}
}
config: {
Expand Down
17 changes: 1 addition & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import {GlobalConfig} from './config'
import * as core from '@actions/core'
import * as github from '@actions/github'
import devTo, {DevToArticleData} from './devto'

async function run(): Promise<void> {
try {
const ms: string = core.getInput('milliseconds')
const something = GlobalConfig.something
core.debug(`Waiting ${ms} milliseconds ...`)
core.debug(`something: ${something}`)
core.debug(new Date().toTimeString())
core.debug(new Date().toTimeString())

core.setOutput('time', new Date().toTimeString())

const nameToGreet = core.getInput('who-to-greet')
core.debug(`Hello ${nameToGreet}!`)

// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
core.debug(`The event payload: ${payload}`)

core.debug(`Hello ${core.getInput('title')}!`)

const devToArticleData: DevToArticleData = {
content: {
article: {
Expand All @@ -32,7 +17,7 @@ async function run(): Promise<void> {
canonical_url: core.getInput('canonical_url'),
published: core.getInput('published'),
series: core.getInput('series'),
organization_id: core.getInput('organization_id')
devto_organization_id: core.getInput('devto_organization_id')
}
},
config: {
Expand Down

0 comments on commit 27a812b

Please sign in to comment.