Auto-sync: updated *.template.docx files #72
This file contains hidden or 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: Process Resume | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - data/resume/docs/*.template.docx | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| create-resumes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| data/resume/ | |
| .github/ | |
| scripts/ | |
| - name: Set up permissions | |
| run: chmod +x data/resume/bin/create-resumes.sh | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Build JAR | |
| working-directory: data/resume | |
| run: | | |
| ./gradlew build | |
| - name: Run resume creation script | |
| working-directory: data/resume | |
| run: ./bin/create-resumes.sh | |
| - name: Upload DOCX to Dropbox | |
| uses: ./.github/actions/dropbox-upload | |
| with: | |
| file_pattern: 'docs/resume*.docx' | |
| dropbox_path: '/about/resume' | |
| working_directory: 'data/resume' | |
| token: ${{ secrets.DROPBOX_ACCESS_TOKEN }} | |
| - name: Upload DOCX as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: resume-docx | |
| path: data/resume/docs/resume*.docx | |
| if-no-files-found: error | |
| convert-to-pdf: | |
| needs: create-resumes | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| data/resume/ | |
| .github/ | |
| scripts/ | |
| - name: Download DOCX artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: resume-docx | |
| path: data/resume/docs | |
| - name: Convert DOCX to PDF | |
| uses: ./.github/actions/docx-to-pdf | |
| with: | |
| file_pattern: 'docs/resume*.docx' | |
| working_directory: 'data/resume' | |
| - name: Upload PDF to Dropbox | |
| uses: ./.github/actions/dropbox-upload | |
| with: | |
| file_pattern: 'docs/resume*.pdf' | |
| dropbox_path: '/about/resume' | |
| working_directory: 'data/resume' | |
| token: ${{ secrets.DROPBOX_ACCESS_TOKEN }} | |
| - name: Upload PDF as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: resume-pdf | |
| path: data/resume/docs/resume*.pdf | |
| if-no-files-found: error | |
| generate-website-content: | |
| needs: [create-resumes] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| scripts/ | |
| docs/assets/ | |
| - name: Use Node.js 20 | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: | | |
| npm install mammoth cheerio | |
| - name: Run the script | |
| run: | | |
| node scripts/update-site-content-json.js | |
| - name: Upload content.json | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: site-content-json | |
| path: docs/assets/content.json | |
| retention-days: 1 | |
| update-git: | |
| needs: [generate-website-content, create-resumes, convert-to-pdf] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| docs/assets/ | |
| - name: Configure git | |
| run: | | |
| git config user.email "[email protected]" | |
| git config user.name "afzalex bot" | |
| # Create orphan branch (no history) | |
| git checkout --orphan fzbot | |
| git reset | |
| git checkout master -- docs/assets/ | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create target folder and copy only generated files | |
| run: | | |
| mkdir -p docs/assets | |
| cp artifacts/resume-docx/*.docx docs/assets/ 2>/dev/null || true | |
| cp artifacts/resume-pdf/*.pdf docs/assets/ 2>/dev/null || true | |
| cp artifacts/site-content-json/content.json docs/assets/ 2>/dev/null || true | |
| - name: Create and push clean fzbot branch | |
| run: | | |
| echo "Git status" | |
| git status | |
| # Stage and commit | |
| git add docs/assets/* | |
| git commit -m "Initial commit with only generated resume files" | |
| # Push forcefully to remote branch | |
| git push -f origin fzbot | |
| notify: | |
| needs: [create-resumes, convert-to-pdf, update-git, generate-website-content] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| .github/ | |
| scripts/ | |
| - name: Determine workflow status | |
| id: workflow-status | |
| run: | | |
| if [[ "${{ needs.create-resumes.result }}" == "success" && \ | |
| "${{ needs.convert-to-pdf.result }}" == "success" && \ | |
| "${{ needs.update-git.result }}" == "success" && \ | |
| "${{ needs.generate-website-content.result }}" == "success" ]]; then | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| echo "subject=Resume Generation Complete" >> $GITHUB_OUTPUT | |
| else | |
| echo "status=failure" >> $GITHUB_OUTPUT | |
| echo "subject=Workflow Failure" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download artifacts | |
| if: steps.workflow-status.outputs.status == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Process success template | |
| if: steps.workflow-status.outputs.status == 'success' | |
| run: | | |
| # List generated files in HTML format and store in a temporary variable | |
| FILES_HTML=$(find artifacts -type f \( -name "resume*.pdf" -o -name "resume*.docx" \) | sort | while read -r file; do | |
| filename=$(basename "$file") | |
| echo "<li><a href=\"https://raw.githubusercontent.com/${{ github.repository }}/fzbot/docs/assets/$filename\">$filename</a></li>" | |
| done | tr '\n' ' ') | |
| # Process HTML template using the stored files list | |
| export REPOSITORY="${{ github.repository }}" | |
| export RUN_ID="${{ github.run_id }}" | |
| export FILES_LIST="$FILES_HTML" | |
| envsubst < .github/templates/success.html > rendered.html | |
| - name: Process failure template | |
| if: steps.workflow-status.outputs.status == 'failure' | |
| run: | | |
| export REPOSITORY="${{ github.repository }}" | |
| export RUN_ID="${{ github.run_id }}" | |
| envsubst < .github/templates/failure.html > rendered.html | |
| - name: Read rendered template | |
| id: read-template | |
| run: | | |
| echo 'html_content<<EOF' >> $GITHUB_OUTPUT | |
| cat rendered.html >> $GITHUB_OUTPUT | |
| echo '' >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| - name: Send Email Notification | |
| uses: ./.github/actions/notify-email | |
| with: | |
| email: '[email protected]' | |
| subject: ${{ steps.workflow-status.outputs.subject }} | |
| html_content: ${{ steps.read-template.outputs.html_content }} | |
| gmail_user: ${{ secrets.GMAIL_USER }} | |
| gmail_app_password: ${{ secrets.GMAIL_APP_PASSWORD }} |