Update Github Profile with my most recent DEV post
@dylan
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
active
last updated:-last event:-
steps.
profile_repo
auth
to use OAuth tokens and API keys in code via theauths object
params
Owner
 
string ·params.owner
Repo
 
string ·params.repo
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
}
4
this.owner = params.owner
this.repo = params.repo
steps.
get_repository_readme
Gets the repository README, given an optional ref. See https://octokit.github.io/rest.js/v18#repos-get-readme
auth
(auths.github)
params
Repo Owner

The user / org who owns the repo

{{steps.profile_repo.owner}}
string ·params.owner
Repo Name

The name of your repository

{{steps.profile_repo.repo}}
string ·params.repo
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
}
23
const { owner, repo, ref } = params
const { Octokit } = require("@octokit/rest")

const octokit = new Octokit({
  auth: auths.github.oauth_access_token,
})

let payload = {
  owner,
  repo,
}

if (ref) {
  payload = {
    owner,
    repo,
    ref,
  }
}

return (await octokit.repos.getReadme(payload)).data
steps.
base64_decode_string
Accepts a base64-encoded string, returns a decoded UTF-8 string
params
Data
{{steps.get_repository_readme.$return_value.content}}
string ·params.data
code
async params => {
1
2
3
}
4
const buffer = Buffer.from(params.data, 'base64');
this.data = buffer.toString('utf8');
steps.
insert_dev_link_in_readme
auth
to use OAuth tokens and API keys in code via theauths object
params
Link
{{event.link}}
string ·params.link
Readme
{{steps.base64_decode_string.data}}
string ·params.readme
Title
{{event.title}}
string ·params.title
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
}
19
const { link, readme, title } = params

if (!link || !readme || !title) {
  $end("No link, title, or README conent found. Please see the step exports above to troubleshoot their absence.")
}

// Match on the content within the DEV tags 
const re = /\<\!\-\-\s*dev\s*\-\-\>(?<link>.*)\<\!\-\-\s*devend\s*\-\-\>/is

const match = readme.match(re)
if (!match || !match.groups) {
  $end("<!-- dev --> comments not found. Exiting")
}

return readme.replace(/\<\!\-\-\s*dev\s*\-\-\>(?<content>.*)\<\!\-\-\s*devend\s*\-\-\>/is, `<!-- dev -->
[${title}](${link})
<!-- devend -->`)
steps.
base64_encode_string
auth
to use OAuth tokens and API keys in code via theauths object
params
Data
{{steps.insert_dev_link_in_readme.$return_value}}
string ·params.data
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
}
4
const buffer = Buffer.from(params.data);
this.data = buffer.toString('base64');
steps.
update_file_contents
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
params
Owner
{{steps.profile_repo.owner}}
string ·params.owner
Repo
{{steps.profile_repo.repo}}
string ·params.repo
Path
README.md
string ·params.path
Content

The new file content, Base64-encoded

{{steps.base64_encode_string.data}}
string ·params.content
SHA

The blob SHA of the file being replaced

{{steps.get_repository_readme.$return_value.sha}}
string ·params.sha
Message

The commit message

Updating latest DEV link to {{event.link}}
string ·params.message
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
}
17
const { owner, repo, path, content, message, sha } = params
const { Octokit } = require("@octokit/rest")

const octokit = new Octokit({
  auth: auths.github.oauth_access_token,
})

this.resp = await octokit.repos.createOrUpdateFileContents({
  owner,
  repo,
  path,
  message,
  content,
  sha
})