Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
My first action is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
glazec committed Feb 17, 2020
1 parent 8ca44b3 commit 623bbe5
Show file tree
Hide file tree
Showing 7,112 changed files with 678,741 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Push web notification'
description: 'Push the web notification if there are new posts.'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node12'
main: 'index.js'
52 changes: 52 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const fetch = require('node-fetch');
const core = require('@actions/core');
const github = require('@actions/github');

try {
// Get newPost.json from your site.
var newPostOnlineSite = await fetch('https://www.inevitable.tech/newPost.json')
newPostOnlineSite = await newPostOnlineSite.json();
newPostOnlineSite = JSON.parse(JSON.stringify(newPostOnlineSite));
// Get newPost.json from your repo.
var newPostRepo = await fetch('https://raw.githubusercontent.com/glazec/glazec.github.io/master/newPost.json')
newPostRepo = await newPostRepo.json();
newPostRepo = JSON.parse(JSON.stringify(newPostRepo))
console.log(newPostOnlineSite)
console.log(newPostRepo)

//publish the site
fetch(process.env.buildHook, { method: 'POST' });

if (newPostOnlineSite.id != newPostRepo.id) {
// push new Post notificaiton

payload = { "title": newPostRepo.title, "message": newPostRepo.summary, "target_url": newPostRepo.url }
const response = await fetch('https://app.webpushr.com/api/v1/notification/send/all', {
method: 'POST',
headers: {
'webpushrKey': process.env.webpushrKey,
'webpushrAuthToken': process.env.webpushrAuthToken,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
const data = await response.json();

if (!response.ok) {
// NOT res.status >= 200 && res.status < 300
return JSON.stringify({ statusCode: data.status, body: data.detail });
}
return (
"Successfully push notification"),



}
else {
return (
"No New Post detected.");
}

} catch (error) {
core.setFailed(error.message);
}
22 changes: 22 additions & 0 deletions node_modules/@babel/code-frame/LICENSE

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

19 changes: 19 additions & 0 deletions node_modules/@babel/code-frame/README.md

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

167 changes: 167 additions & 0 deletions node_modules/@babel/code-frame/lib/index.js

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

55 changes: 55 additions & 0 deletions node_modules/@babel/code-frame/package.json

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

22 changes: 22 additions & 0 deletions node_modules/@babel/compat-data/LICENSE

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

4 changes: 4 additions & 0 deletions node_modules/@babel/compat-data/corejs2-built-ins.js

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

Loading

0 comments on commit 623bbe5

Please sign in to comment.