|
| 1 | +name: Create Task 1 Issue |
| 2 | + |
| 3 | +on: |
| 4 | + fork: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + username: |
| 8 | + description: 'GitHub username to personalize the issue' |
| 9 | + required: true |
| 10 | + default: 'your_github_username' |
| 11 | + |
| 12 | +permissions: |
| 13 | + issues: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + create_issue: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v6 |
| 22 | + |
| 23 | + - name: Set up GitHub user |
| 24 | + id: get_user |
| 25 | + run: | |
| 26 | + echo "USERNAME=$(jq -r .sender.login $GITHUB_EVENT_PATH)" >> $GITHUB_ENV |
| 27 | +
|
| 28 | + - name: Create a personalized issue file |
| 29 | + id: create_file |
| 30 | + run: | |
| 31 | + USERNAME=${{ env.USERNAME }} |
| 32 | + TEMPLATE_PATH="../gitcaos/.github/workflows/template_task_1.md" |
| 33 | + ISSUE_FILE="../gitcaos/.github/workflows/issue_temp.md" |
| 34 | +
|
| 35 | + echo "Username is: $USERNAME" |
| 36 | +
|
| 37 | + # Check if USERNAME is defined |
| 38 | + if [ -z "$USERNAME" ]; then |
| 39 | + echo "USERNAME is not defined." |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | +
|
| 43 | + # Remove temp file if it already exists |
| 44 | + if [ -f "$ISSUE_FILE" ]; then |
| 45 | + echo "Removing existing file: $ISSUE_FILE" |
| 46 | + rm $ISSUE_FILE |
| 47 | + fi |
| 48 | +
|
| 49 | + # Replace placeholder with actual username |
| 50 | + sed "s/your_github_username/${USERNAME}/g" $TEMPLATE_PATH > $ISSUE_FILE |
| 51 | +
|
| 52 | + # Check if the file was created |
| 53 | + if [ -f "$ISSUE_FILE" ]; then |
| 54 | + echo "$ISSUE_FILE created successfully." |
| 55 | + else |
| 56 | + echo "$ISSUE_FILE was not created." |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Create welcome issue |
| 61 | + uses: peter-evans/create-issue-from-file@v6 |
| 62 | + with: |
| 63 | + title: "Task 1: Create file: `${{ env.USERNAME }}.txt`" |
| 64 | + content-filepath: ../gitcaos/.github/workflows/issue_temp.md |
| 65 | + labels: 'solo-practice, task-1' |
| 66 | + assignees: ${{ env.USERNAME }} |
0 commit comments