Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
feat(stats): save user activity #18
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Sep 5, 2020
1 parent 5469145 commit 06b61c2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/community.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
on:
issues:
types: [ opened ]
issue_comment:
types: [ created ]
pull_request:
types: [ opened ]
pull_request_review:
types: [ submitted ]
pull_request_review_comment:
types: [ created ]

jobs:
welcome:
Expand All @@ -13,6 +19,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: '# Congratulations :tada:\nThis is your first **Issue**! Welcome to the community :nerd:'
pr-message: '# Congratulations :tada:\nThis is your first **Pull Request**! Welcome to the community :nerd:'
- uses: EddieJaoudeCommunity/gh-action-community@v0.1
- uses: EddieJaoudeCommunity/gh-action-community@eddiejaoude-issue-18
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
firebase-ket: ${{ secrets.FIREBASE_KEY }}
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
github-token:
description: 'GitHub token for repo'
required: true
firebase-key:
description: 'Firebase key'
required: true
runs:
using: 'node12'
main: 'index.js'
main: 'src/index.js'
12 changes: 0 additions & 12 deletions index.js

This file was deleted.

25 changes: 25 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const core = require('@actions/core');
const github = require('@actions/github');
const admin = require('firebase-admin');

(async () => {
try {
const firebaseKey = core.getInput('firebase-key', { required: true });

admin.initializeApp({
credential: admin.credential.cert(JSON.parse(firebaseKey)),
});

const db = admin.firestore();
const author = github.context.payload.sender;
const type = process.env.GITHUB_EVENT_NAME;

const docRef = db.collection('usersGitHub').doc(author.id);
await docRef.set({
...author,
type: admin.firestore.FieldValue.increment(1)
}, { merge: true });
} catch (error) {
core.setFailed(error.message);
}
})();

0 comments on commit 06b61c2

Please sign in to comment.