Skip to content

Submit Resource

Submit Resource #5

name: Add Repository
on:
workflow_dispatch:
inputs:
repository_url:
description: 'Repository URL or shorthand (e.g., libAudioFlux/audioFlux)'
required: true
jobs:
add_repository:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Imposta la versione di Node.js su 16
- name: Install Dependencies
run: |
npm install github-api
- name: Add Repository if Not Exists
run: |
const fs = require('fs');
const github = require('@actions/github');
const repositoryUrl = process.env.INPUT_REPOSITORY_URL.trim();
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
const filePath = '.github/SUBMITTED.md';
const contentToAppend = `|[${repo}](${repositoryUrl})||[![](https://img.shields.io/github/languages/top/${owner}/${repo}?color=pink&style=flat-square)](https://github.com/${owner}/${repo}/graphs/contributors)|[![](https://flat.badgen.net/github/license/${owner}/${repo}?label=)](https://github.com/${owner}/${repo}/blob/master/LICENSE)|[![](https://flat.badgen.net/github/last-commit/${owner}/${repo}?label=)](https://github.com/${owner}/${repo}/graphs/code-frequency)|\n`;
try {
const existingContent = fs.readFileSync(filePath, 'utf8');
if (!existingContent.includes(repositoryUrl)) {
fs.appendFileSync(filePath, contentToAppend);
console.log(`Repository ${repositoryUrl} added to ${filePath}`);
} else {
console.log(`Repository ${repositoryUrl} already exists in ${filePath}`);
}
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
env:
INPUT_REPOSITORY_URL: ${{ github.event.inputs.repository_url }}