diff --git a/.github/ISSUE_TEMPLATE/subscription.yaml b/.github/ISSUE_TEMPLATE/subscription.yaml new file mode 100644 index 0000000..cf69607 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/subscription.yaml @@ -0,0 +1,137 @@ +name: Subscription to the careathon 2024 +description: Please fill in this form to subscribe to the careathon 2024 +title: "[auto] - Subscription to the careathon 2024" +body: + - type: markdown + attributes: + value: | + Fill in the formular bellow to subscribe to the Careathon 2024. + Careathon 2024. + - type: input + id: github_handle + attributes: + label: What is your GitHub handle ? + description: | + Give us your GitHub handle, you can find it at the end of your https://github.com/ + validations: + required: true + - type: markdown + attributes: + value: | + ## If you compete as a team, provide the name of your team, and the GitHub handle of the other participants. + - type: input + id: team_name + attributes: + label: What is the name of your team + description: | + If you compete as a team, choose the name of your team. + - type: input + id: contestant_1_handle + attributes: + label: What is the GitHub handle of the second contestant ? + description: | + If you compete as a team, provide us the GitHub handle of the second contestant ? + validations: + required: true + - type: input + id: contestant_2_handle + attributes: + label: What is the GitHub handle of the third contestant ? + description: | + If you compete as a team, provide us the GitHub handle of the third contestant ? + validations: + required: true + - type: dropdown + id: city + attributes: + label: Which city do you live in ? (Dans quel ville vivez vous) + options: + - Other + - Douala + - Yaoundé + - Garoua + - Bamenda + - Maroua + - Nkongsamba + - Bafoussam + - Ngaoundéré + - Bertoua + - Loum + - Kumba + - Edéa + - Kumbo + - Foumban + - Mbouda + - Dschang + - Limbé + - Ebolowa + - Kousséri + - Guider + - Meiganga + - Yagoua + - Mbalmayo + - Bafang + - Tiko + - Bafia + - Wum + - Kribi + - Buea + - Sangmélima + - Foumbot + - Bangangté + - Batouri + - Banyo + - Nkambé + - Bali + - Mbanga + - Mokolo + - Melong + - Manjo + - Garoua-Boulaï + - Mora + - Kaélé + - Tibati + - Ndop + - Akonolinga + - Eséka + - Mamfé + - Obala + - Muyuka + - Nanga-Eboko + - Abong-Mbang + - Fundong + - Nkoteng + - Fontem + - Mbandjock + - Touboro + - Ngaoundal + - Yokadouma + - Pitoa + - Tombel + - Kékem + - Magba + - Bélabo + - Tonga + - Maga + - Koutaba + - Blangoua + - Guidiguis + - Bogo + - Batibo + - Yabassi + - Figuil + - Makénéné + - Gazawa + - Tcholliré + - type: input + id: other_city + attributes: + label: If you live in another city, please enter the city you currently live in + - type: input + id: other_country + attributes: + label: If you live outside of Cameroon, please enter the country you currently live in + - type: input + id: free_comment + attributes: + label: "Would you like to share something regarding your participation to the Careathon" diff --git a/.github/ISSUE_TEMPLATE/subscription_fr.yaml b/.github/ISSUE_TEMPLATE/subscription_fr.yaml new file mode 100644 index 0000000..48ea01e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/subscription_fr.yaml @@ -0,0 +1,137 @@ +name: Francais - Inscription au careathon 2024 +description: Remplissez ce formulaire pour vous inscrire au careathon 2024 +title: "[auto] - Inscription au careathon 2024" +body: + - type: markdown + attributes: + value: | + Remplissez le formulaire ci-dessous pour valider votre inscription au + Careathon 2024. + - type: input + id: github_handle + attributes: + label: Quel est votre handle GitHub? + description: | + Entrez votre handle GitHub, vous le trouverez a la fin de l'url de votre profile https://github.com/ + validations: + required: true + - type: markdown + attributes: + value: | + ## Si vous participez en equipe, fournissez un nom d'equipe, et les handle GitHub des autres participants. + - type: input + id: team_name + attributes: + label: Saisissez le nom de votre equipe + description: | + Si vous participez en equipe, saisissez votre nom d'equipe. + - type: input + id: contestant_1_handle + attributes: + label: Saisissez le handle GitHub du second participant. + description: | + Si vous participez en equipe, saisissez le handle GitHub du deuxieme participant. + validations: + required: true + - type: input + id: contestant_2_handle + attributes: + label: Saisissez le handle GitHub du troisieme participant. + description: | + Si vous participez en equipe, saisissez le handle GitHub du troisieme participant. + validations: + required: true + - type: dropdown + id: city + attributes: + label: Dans quelle ville vivez vous? + options: + - Other + - Douala + - Yaoundé + - Garoua + - Bamenda + - Maroua + - Nkongsamba + - Bafoussam + - Ngaoundéré + - Bertoua + - Loum + - Kumba + - Edéa + - Kumbo + - Foumban + - Mbouda + - Dschang + - Limbé + - Ebolowa + - Kousséri + - Guider + - Meiganga + - Yagoua + - Mbalmayo + - Bafang + - Tiko + - Bafia + - Wum + - Kribi + - Buea + - Sangmélima + - Foumbot + - Bangangté + - Batouri + - Banyo + - Nkambé + - Bali + - Mbanga + - Mokolo + - Melong + - Manjo + - Garoua-Boulaï + - Mora + - Kaélé + - Tibati + - Ndop + - Akonolinga + - Eséka + - Mamfé + - Obala + - Muyuka + - Nanga-Eboko + - Abong-Mbang + - Fundong + - Nkoteng + - Fontem + - Mbandjock + - Touboro + - Ngaoundal + - Yokadouma + - Pitoa + - Tombel + - Kékem + - Magba + - Bélabo + - Tonga + - Maga + - Koutaba + - Blangoua + - Guidiguis + - Bogo + - Batibo + - Yabassi + - Figuil + - Makénéné + - Gazawa + - Tcholliré + - type: input + id: other_city + attributes: + label: Si vous vivez dans une autre ville, saisissez la ville dans laquelle vous vivez. + - type: input + id: other_country + attributes: + label: Si vouz vivez hors du Cameroun, saisissez le Pays dans lequel vous vivez. + - type: input + id: free_comment + attributes: + label: "Avez vous quelque chose à nous dire concernant les raisons de votre participation à ce Careathon ?" diff --git a/.github/workflows/subscription.yaml b/.github/workflows/subscription.yaml new file mode 100644 index 0000000..016dece --- /dev/null +++ b/.github/workflows/subscription.yaml @@ -0,0 +1,46 @@ +name: Process survey's entry +on: + issues: + types: [ opened ] + +concurrency: 'main' +jobs: + take_survey: + runs-on: ubuntu-latest + if: contains(github.event.issue.title, '[auto] - Subscription to the careathon') + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '16' + + - uses: stefanbuck/github-issue-parser@v3 + id: issue-parser + with: + template-path: .github/ISSUE_TEMPLATE/subscription.yaml + + - run: echo '${{ steps.issue-parser.outputs.jsonString }}' > survey_submission.json + + - run: | + cat survey_submission.json | jq + + - name: send custom message to the osscameroon group + uses: appleboy/telegram-action@v0.1.1 + with: + to: ${{ secrets.TELEGRAM_CAREATHON_ADMIN_GROUP_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: > + A new subscription was submitted on the issue bellow, please review the subscription in 48 hours. + ${{ github.event.issue.html_url }} + + - name: Add comment + run: gh issue comment "$NUMBER" --body "$BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + BODY: > + :sparkles: Thanks for submitting your application. :sparkles: + + Your application will be reviewed in 48 hours. diff --git a/.github/workflows/subscription_fr.yaml b/.github/workflows/subscription_fr.yaml new file mode 100644 index 0000000..0d87555 --- /dev/null +++ b/.github/workflows/subscription_fr.yaml @@ -0,0 +1,46 @@ +name: Process survey's entry +on: + issues: + types: [ opened ] + +concurrency: 'main' +jobs: + take_survey: + runs-on: ubuntu-latest + if: contains(github.event.issue.title, '[auto] - Inscription au careathon') + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '16' + + - uses: stefanbuck/github-issue-parser@v3 + id: issue-parser + with: + template-path: .github/ISSUE_TEMPLATE/subscription_fr.yaml + + - run: echo '${{ steps.issue-parser.outputs.jsonString }}' > survey_submission.json + + - run: | + cat survey_submission.json | jq + + - name: send custom message to the osscameroon group + uses: appleboy/telegram-action@v0.1.1 + with: + to: ${{ secrets.TELEGRAM_CAREATHON_ADMIN_GROUP_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: > + A new subscription was submitted on the issue bellow, please review the subscription in 48 hours. + ${{ github.event.issue.html_url }} + + - name: Add comment + run: gh issue comment "$NUMBER" --body "$BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + BODY: > + :sparkles: Thanks for submitting your application. :sparkles: + + Your application will be reviewed in 48 hours. diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..cc945b1 --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,132 @@ +name: Add subscription +on: + issues: + types: [ closed ] + +concurrency: 'main' +jobs: + add_participant: + runs-on: ubuntu-latest + if: ${{ contains(github.event.issue.title, '[auto] - Subscription to the careathon') && contains(github.event.issue.labels.*.name, 'valid_submission') }} + steps: + - uses: actions/checkout@v2 + + - uses: stefanbuck/github-issue-parser@v3 + id: issue-parser + with: + template-path: .github/ISSUE_TEMPLATE/subscription.yaml + + - run: echo '${{ steps.issue-parser.outputs.jsonString }}' > survey_submission.json + + - run: | + cat survey_submission.json | jq + + - name: Set convert json to yaml + shell: bash + run: | + cat survey_submission.json | yq e '{"items": [.]}' -P - > survey_submission.yaml + + - run: cat survey_submission.yaml + + - name: Set convert json to yaml + shell: bash + run: | + yq ea '. as $item ireduce ({}; . *+ $item)' -i ./src/res/survey.yaml survey_submission.yaml + + - run: cat ./src/res/survey.yaml + + + - name: create a repository template + run: | + slugify () { + echo "$1" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z + } + TEAM_NAME=$(yq ".items[-1].team_name" < ./src/res/survey.yaml) + TEAM_NAME=$(slugify "$TEAM_NAME") + USERNAME=$(yq ".items[-1].github_handle" < ./src/res/survey.yaml) + PREFIX=careathon-2024 + if [ ! -z "$TEAM_NAME" ]; then + REPONAME=$PREFIX-$TEAM_NAME + else + REPONAME=$PREFIX-$USERNAME + fi + echo "REPONAME=$REPONAME" >> $GITHUB_ENV + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/test-template/generate \ + -f "owner=osscameroon" -f "name=$REPONAME" -f "description=This is your first repository" -F "include_all_branches=false" -F "private=true" + + # Add the repository name + yq e -i ".items[-1].repository = \"$REPONAME\"" ./src/res/survey.yaml + + env: + GH_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }} + + - 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 ./src/res/survey.yaml && \ + git commit -m 'new survey answer' && \ + git push + + - name: add collaborators + run: | + USERNAME=$(yq ".items[-1].github_handle" < ./src/res/survey.yaml) + USERNAME_1=$(yq ".items[-1].contestant_1_handle" < ./src/res/survey.yaml) + USERNAME_2=$(yq ".items[-1].contestant_2_handle" < ./src/res/survey.yaml) + + if [ ! -z "$USERNAME" ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME \ + -f "permission=push" + fi + + if [ ! -z "$USERNAME_1" ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME_1 \ + -f "permission=push" + fi + + if [ ! -z $USERNAME_2 ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME_2 \ + -f "permission=push" + fi + + env: + GH_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }} + + - name: send custom message to the osscameroon group + uses: appleboy/telegram-action@v0.1.1 + with: + to: ${{ secrets.TELEGRAM_CAREATHON_ADMIN_GROUP_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: > + A new participant has been approved. + ${{ github.event.issue.html_url }} + + - name: Add comment + run: | + BODY=":sparkles: Your subscription has been approved :sparkles: + + The https://github.com/osscameroon/$REPONAME repository was created, for you. Read the repositories README.md to find out more about the competion." + + gh issue comment "$NUMBER" --body "$BODY" + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} diff --git a/.github/workflows/validate_fr.yaml b/.github/workflows/validate_fr.yaml new file mode 100644 index 0000000..ebb338a --- /dev/null +++ b/.github/workflows/validate_fr.yaml @@ -0,0 +1,130 @@ +name: Add subscription +on: + issues: + types: [ closed ] + +concurrency: 'main' +jobs: + add_participant: + runs-on: ubuntu-latest + if: ${{ contains(github.event.issue.title, '[auto] - Inscription au careathon') && contains(github.event.issue.labels.*.name, 'valid_submission') }} + steps: + - uses: actions/checkout@v2 + + - uses: stefanbuck/github-issue-parser@v3 + id: issue-parser + with: + template-path: .github/ISSUE_TEMPLATE/subscription_fr.yaml + + - run: echo '${{ steps.issue-parser.outputs.jsonString }}' > survey_submission.json + + - run: | + cat survey_submission.json | jq + + - name: Set convert json to yaml + shell: bash + run: | + cat survey_submission.json | yq e '{"items": [.]}' -P - > survey_submission.yaml + + - run: cat survey_submission.yaml + + - name: Set convert json to yaml + shell: bash + run: | + yq ea '. as $item ireduce ({}; . *+ $item)' -i ./src/res/survey.yaml survey_submission.yaml + + - run: cat ./src/res/survey.yaml + + - name: create a repository template + run: | + slugify () { + echo "$1" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z + } + TEAM_NAME=$(yq ".items[-1].team_name" < ./src/res/survey.yaml) + TEAM_NAME=$(slugify "$TEAM_NAME") + USERNAME=$(yq ".items[-1].github_handle" < ./src/res/survey.yaml) + PREFIX=careathon-2024 + if [ ! -z "$TEAM_NAME" ]; then + REPONAME=$PREFIX-$TEAM_NAME + else + REPONAME=$PREFIX-$USERNAME + fi + echo "REPONAME=$REPONAME" >> $GITHUB_ENV + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/test-template/generate \ + -f "owner=osscameroon" -f "name=$REPONAME" -f "description=This is your first repository" -F "include_all_branches=false" -F "private=true" + + # Add the repository name + yq e -i ".items[-1].repository = \"$REPONAME\"" ./src/res/survey.yaml + + env: + GH_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }} + + - 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 ./src/res/survey.yaml && \ + git commit -m 'new survey answer' && \ + git push + + - name: add collaborators + run: | + USERNAME=$(yq ".items[-1].github_handle" < ./src/res/survey.yaml) + USERNAME_1=$(yq ".items[-1].contestant_1_handle" < ./src/res/survey.yaml) + USERNAME_2=$(yq ".items[-1].contestant_2_handle" < ./src/res/survey.yaml) + + if [ ! -z "$USERNAME" ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME \ + -f "permission=push" + fi + + if [ ! -z "$USERNAME_1" ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME_1 \ + -f "permission=push" + fi + + if [ ! -z $USERNAME_2 ]; then + gh api \ + --method PUT \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/osscameroon/$REPONAME/collaborators/$USERNAME_2 \ + -f "permission=push" + fi + env: + GH_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }} + + - name: send custom message to the osscameroon group + uses: appleboy/telegram-action@v0.1.1 + with: + to: ${{ secrets.TELEGRAM_CAREATHON_ADMIN_GROUP_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: > + A new participant has been approved. + ${{ github.event.issue.html_url }} + + - name: Add comment + run: | + BODY=":sparkles: Your subscription has been approved :sparkles: + + The https://github.com/osscameroon/$REPONAME repository was created, for you. Read the repositories README.md to find out more about the competion." + + gh issue comment "$NUMBER" --body "$BODY" + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..684ef6a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# careathon-2024 \ No newline at end of file diff --git a/src/res/survey.yaml b/src/res/survey.yaml new file mode 100644 index 0000000..e69de29