Skip to content

Challenges/1 cubo simples/java/adriel matielo #375

Challenges/1 cubo simples/java/adriel matielo

Challenges/1 cubo simples/java/adriel matielo #375

name: helloworld checker
permissions:
pull-requests: write
contents: write
on:
pull_request_target:
paths:
- 'challenges/**'
- '!challenges/0-hello-world/**'
jobs:
check-challenge-0:
name: Checks if member completed the "00 - Hello World" challenge
runs-on: ubuntu-latest
steps:
- name: Checks challenge 0
uses: actions/checkout@v3
- name: Checking
run: |
CHALLENGE_PATH="challenges/0-hello-world"
GITHUB_USERNAME="$GITHUB_ACTOR"
# procura pelo diretório e retorna o caminho
USER_PATH=$(find "$CHALLENGE_PATH" -mindepth 2 -maxdepth 2 -type d -iname "$GITHUB_USERNAME")
if [ -n "$USER_PATH" ]; then
# extrai o nome da pasta da linguagem
LANG_FOLDER=$(basename $(dirname "$USER_PATH"))
echo "Challenge-0 completado por $GITHUB_USERNAME na linguagem: $LANG_FOLDER." >> $GITHUB_STEP_SUMMARY
exit 0 # Sucesso
fi
# Se não entregar falha a action
echo "Challenge-0 não foi entregue por $GITHUB_USERNAME em nenhuma linguagem." >> $GITHUB_STEP_SUMMARY
exit 1
- name: Notify Failure
if: failure()
run: |
REPO="${{ github.repository }}"
PR_NUMBER="${{ github.event.number }}"
MESSAGE="Salve @$GITHUB_ACTOR, você esqueceu de mandar o desafio 0!"
curl -X POST "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$MESSAGE\"}"
- name: Add label
if: failure()
run: |
REPO="${{ github.repository }}"
PR_NUMBER="${{ github.event.number }}"
LABEL="Necessita do desafio 0"
curl -X POST "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"labels\": [\"$LABEL\"]}"