Skip to content

Commit

Permalink
feat: generate podcasts with an issue form
Browse files Browse the repository at this point in the history
  • Loading branch information
geromegrignon committed May 7, 2024
1 parent cde8797 commit 124d785
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/add-podcast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: New podcast
description: submit a new podcast for angular-hub.com/podcasts
title: '[New podcast]: '
body:
- type: input
id: name
attributes:
label: Podcast name
validations:
required: true
- type: input
id: url
attributes:
label: Podcast URL
description: Choose the preferred platform to share the podcast content
validations:
required: true
- type: input
id: logo
attributes:
label: Podcast logo
- type: input
id: language
attributes:
label: Language
validations:
required: true
- type: markdown
attributes:
value: >-
This template was generated with [Issue Forms
Creator](https://issue-forms-creator.netlify.app)
40 changes: 40 additions & 0 deletions .github/workflows/podcast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Add podcast
on:
issues:
types:
- labeled
concurrency: 'main'
jobs:
add_podcast:
if: github.event.label.name == 'podcast-approved'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- uses: stefanbuck/github-issue-praser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/add-podcast.yml

- run: echo '${{ steps.issue-parser.outputs.jsonString }}' > add-podcast.json

- run: cat add-podcast.json

- run: node ./scripts/add-podcast.js

- name: Commit changes
shell: bash
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com" && \
git config --global user.name "github-actions[bot]" && \
git add README.md && \
git commit -m 'Add podcast' && \
git push
- uses: peter-evans/close-issue@v1
with:
comment: 'Podcast added: thanks for your contribution!'
24 changes: 24 additions & 0 deletions scripts/add-podcast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require('fs');
const order = require('./../add-podcast.json');

const [name, url, logo, language] = Object.values(order);

let podcastRaw = fs.readFileSync(
'./angular-hub/src/public/assets/data/podcast.json',
);
let podcastData = JSON.parse(podcastRaw);
let json = JSON.stringify(
[
...podcastData,
{
name,
url,
logo,
language,
},
],
null,
2,
);

fs.writeFileSync('./angular-hub/src/public/assets/data/podcast.json', json);

0 comments on commit 124d785

Please sign in to comment.