Skip to content

git-in-here.yml

git-in-here.yml #128

# If a PR is opened within October, then add Hacktoberfest label
# Also supports other challenges, like NovemberSoftwareChallenge and 24PR-December
name: 🎃 Add Hacktoberfest Label
on:
pull_request_target:
types:
- opened
permissions:
issues: write
pull-requests: write
jobs:
add-label:
runs-on: ubuntu-latest
steps:
- name: 📆 Check current month
id: check-date
run: |
MONTH=$(date +'%m')
if [[ "$MONTH" == "10" ]]; then
echo "::set-output name=month::october"
elif [[ "$MONTH" == "11" ]]; then
echo "::set-output name=month::november"
elif [[ "$MONTH" == "12" ]]; then
echo "::set-output name=month::december"
else
echo "::set-output name=month::other"
fi
- name: 🏷️ Add labels based on month
uses: actions/github-script@v3
with:
github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
script: |
let labelsToAdd = [];
switch ("${{ steps.check-date.outputs.month }}") {
case "october":
labelsToAdd.push('hacktoberfest-accepted');
break;
case "november":
labelsToAdd.push('NovemberSoftwareChallenge');
break;
case "december":
labelsToAdd.push('24PR-December');
break;
}
if (labelsToAdd.length) {
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd
});
}