Skip to content

Commit f0b137c

Browse files
refactor: move the socials text from finish-exercise workflow to the exercise-finished template (#76)
1 parent 3135d1c commit f0b137c

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

.github/workflows/finish-exercise.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,6 @@ jobs:
4343
path: exercise-toolkit
4444
ref: ${{ env.EXERCISE_TOOLKIT_REF }}
4545

46-
- name: Encode socials text
47-
id: encode-socials-text
48-
uses: actions/github-script@v7
49-
env:
50-
EXERCISE_TITLE: ${{ inputs.exercise-title }}
51-
with:
52-
script: |
53-
const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
54-
const exerciseTitle = process.env.EXERCISE_TITLE;
55-
56-
const firstLine = exerciseTitle && exerciseTitle.trim() !== ''
57-
? `I just completed the "${exerciseTitle}" GitHub Skills hands-on exercise! 🎉`
58-
: `I just completed a GitHub Skills hands-on exercise! 🎉`;
59-
60-
const socialsText = `${firstLine}
61-
62-
${repoUrl}
63-
64-
#GitHubSkills #OpenSource #GitHubLearn
65-
`;
66-
67-
const encodedText = encodeURIComponent(socialsText);
68-
core.setOutput('encoded-text', encodedText);
69-
7046
- name: Build congratulations message from template
7147
id: build-new-readme
7248
uses: skills/action-text-variables@v3
@@ -75,7 +51,8 @@ jobs:
7551
template-vars: |
7652
login: ${{ github.actor }}
7753
issue_url: ${{ inputs.issue-url }}
78-
encoded_socials_text: ${{ steps.encode-socials-text.outputs.encoded-text }}
54+
exercise_title: ${{ inputs.exercise-title }}
55+
repository_url: https://github.com/${{ github.repository }}
7956
8057
- name: Overwrite README
8158
env:

markdown-templates/readme/exercise-finished.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
{% set socials_text -%}
2+
{%- if exercise_title -%}
3+
I just completed the "{{ exercise_title }}" GitHub Skills hands-on exercise! 🎉
4+
{%- else -%}
5+
I just completed a GitHub Skills hands-on exercise! 🎉
6+
{%- endif %}
7+
8+
{{ repository_url }}
9+
10+
#GitHubSkills #OpenSource #GitHubLearn
11+
{%- endset -%}
112

213
<div align="center">
314

@@ -11,20 +22,21 @@
1122

1223
**Show off your new skills and inspire others!**
1324

14-
<a href="https://twitter.com/intent/tweet?text={{ encoded_socials_text }}" target="_blank" rel="noopener noreferrer">
25+
<a href="https://twitter.com/intent/tweet?text={{ socials_text | urlencode }}" target="_blank" rel="noopener noreferrer">
1526
<img src="https://img.shields.io/badge/Share%20on%20X-1da1f2?style=for-the-badge&logo=x&logoColor=white" alt="Share on X" />
1627
</a>
17-
<a href="https://bsky.app/intent/compose?text={{ encoded_socials_text }}" target="_blank" rel="noopener noreferrer">
28+
<a href="https://bsky.app/intent/compose?text={{ socials_text | urlencode }}" target="_blank" rel="noopener noreferrer">
1829
<img src="https://img.shields.io/badge/Share%20on%20Bluesky-0085ff?style=for-the-badge&logo=bluesky&logoColor=white" alt="Share on Bluesky" />
1930
</a>
20-
<a href="https://www.linkedin.com/feed/?shareActive=true&text={{ encoded_socials_text }}" target="_blank" rel="noopener noreferrer">
31+
<a href="https://www.linkedin.com/feed/?shareActive=true&text={{ socials_text | urlencode }}" target="_blank" rel="noopener noreferrer">
2132
<img src="https://img.shields.io/badge/Share%20on%20LinkedIn-0077b5?style=for-the-badge&logo=linkedin&logoColor=white" alt="Share on LinkedIn" />
2233
</a>
2334

2435
### 🎯 What's Next?
36+
2537
**Keep the momentum going!**
2638

27-
[![](https://img.shields.io/badge/Return%20to%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)]({{{ issue_url }}})
39+
[![](https://img.shields.io/badge/Return%20to%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)]({{ issue_url }})
2840
[![GitHub Skills](https://img.shields.io/badge/Explore%20GitHub%20Skills-000000?style=for-the-badge&logo=github&logoColor=white)](https://learn.github.com/skills))
2941

3042
*There's no better way to learn than building things!* 🚀

0 commit comments

Comments
 (0)