Resume #645
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Resume | |
on: | |
discussion: | |
types: [ created, edited ] | |
pull_request: | |
types: [ labeled ] | |
jobs: | |
discussion-comment-initial: | |
name: Initial comment | |
uses: shield-wall/myprofile/.github/workflows/discussion-comment.yaml@master | |
if: github.event_name == 'discussion' | |
with: | |
discussionId: ${{github.event.discussion.number}} | |
body: | | |
Your resume started to be processed :rocket: | |
:bell: When it's done we will notify you here | |
:star: Pipeline: https://github.com/shield-wall/myprofile/actions/runs/${{github.run_id}} | |
resume: | |
runs-on: ubuntu-latest | |
name: Generate pdf | |
if: github.event_name == 'discussion' || github.event.label.name == 'template' | |
outputs: | |
yaml-lint: ${{ steps.yaml-lint-output.outputs.stdout }} | |
steps: | |
- uses: actions/checkout@v3 | |
# https://github.com/TypeStrong/ts-node/issues/1997#issuecomment-1864051092 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18.18.2' | |
- uses: actions/cache@v3 | |
with: | |
key: frontend-${{ hashFiles('**/package-lock.json') }} | |
path: | | |
node_modules | |
.cache | |
restore-keys: | | |
frontend- | |
- run: npm install | |
# Process from discussion. | |
- name: Get content from discussion's description | |
if: github.event_name == 'discussion' | |
uses: DamianReeves/write-file-action@master | |
with: | |
path: ./public/data.md | |
contents: ${{github.event.discussion.body}} | |
# Process from pull request. | |
- if: github.event_name == 'pull_request' | |
run: npm run node:copy-data | |
- run: npm run build | |
- name: Generate files | |
run: | | |
python3 -m http.server --directory dist &> /dev/null & | |
pid=$! | |
sleep 1 | |
node -v | |
npm run node:generate:pdf | |
npm run node:generate:card | |
kill "${pid}" | |
cp data/resume.html.dist data/files/resume.html | |
sed -i -E "s|##IMAGE_URL##|https://bucket.myprofile.pro/users/${{github.actor}}/user-card-default.webp?${{github.run_id}}|" data/files/resume.html | |
sed -i -E "s|##PDF_URL##|https://bucket.myprofile.pro/users/${{github.actor}}/resume-default.pdf?${{github.run_id}}|" data/files/resume.html | |
- name: Upload files to bucket | |
run: | | |
npm run cloud:bucket:object put -- --file=data/files/resume-default.pdf myprofile/users/${{github.actor}}/resume-default.pdf | |
npm run cloud:bucket:object put -- --file=data/files/user-card-default.webp myprofile/users/${{github.actor}}/user-card-default.webp | |
npm run cloud:bucket:object put -- --content-type=text/html --file=data/files/resume.html myprofile/users/${{github.actor}}/resume.html | |
env: | |
CLOUDFLARE_ACCOUNT_ID: ${{secrets.CLOUDFLARE_ACCOUNT_ID}} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
discussion-comment-success: | |
name: Success comment | |
uses: shield-wall/myprofile/.github/workflows/discussion-comment.yaml@master | |
if: github.event_name == 'discussion' && needs.resume.result == 'success' | |
needs: resume | |
with: | |
discussionId: ${{github.event.discussion.number}} | |
# discussionId: 755 | |
body: | | |
:white_check_mark: Your resume was generated with success :tada: :tada:, you can access using the link bellow. | |
**:page_with_curl: https://bucket.myprofile.pro/users/${{github.actor}}/resume.html?run_id=${{github.run_id}}** | |
discussion-comment-failure: | |
name: Failure comment | |
uses: shield-wall/myprofile/.github/workflows/discussion-comment.yaml@master | |
if: ${{ failure() && github.event_name == 'discussion' }} | |
needs: resume | |
with: | |
discussionId: ${{github.event.discussion.number}} | |
body: | | |
:x: :bangbang: We couldn't generate your resume :disappointed_relieved: , we found out this issue related with your **yaml syntax**. | |
Please fix the **issue** bellow and after that **edit your discussion's description** to try again :arrows_clockwise: :wink: | |
:point_down: :point_down: | |
```bash | |
${{needs.resume.outputs.yaml-lint}} | |
``` |