Add Bluesky likes, replies, reposts & quotes interactions to posts #45
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: Build and Deploy Example Site | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| types: [opened, synchronize, reopened, closed] | |
| push: | |
| branches: | |
| - main | |
| - master | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| pull-requests: write | |
| concurrency: | |
| group: "pages-${{ github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: github.event.action != 'closed' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v2 | |
| with: | |
| hugo-version: '0.135.0' | |
| extended: true | |
| - name: Setup theme | |
| run: | | |
| mkdir -p exampleSite/themes | |
| THEME_NAME=$(basename "$GITHUB_REPOSITORY" | sed 's/^hugo-theme-//') | |
| ln -s $(pwd) "exampleSite/themes/${THEME_NAME}" | |
| - name: Build example site | |
| run: | | |
| cd exampleSite | |
| REPO_OWNER="${{ github.repository_owner }}" | |
| REPO_NAME="${{ github.event.repository.name }}" | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BRANCH_NAME="${{ github.head_ref }}" | |
| SAFE_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9-]/-/g') | |
| BASE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}/${SAFE_BRANCH}/" | |
| else | |
| BASE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}/" | |
| fi | |
| hugo --minify --baseURL "${BASE_URL}" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: exampleSite/public | |
| deploy-main: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: > | |
| github.event_name == 'push' && | |
| (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| deploy-pr-preview: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'pull_request' && github.event.action != 'closed' | |
| steps: | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: github-pages | |
| path: artifact | |
| - name: Extract artifact | |
| run: | | |
| cd artifact | |
| tar -xf artifact.tar | |
| rm artifact.tar | |
| - name: Deploy PR preview | |
| run: | | |
| BRANCH_NAME="${{ github.head_ref }}" | |
| SAFE_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9-]/-/g') | |
| # Create or update PR preview directory | |
| mkdir -p "gh-pages/${SAFE_BRANCH}" | |
| rm -rf "gh-pages/${SAFE_BRANCH}"/* | |
| cp -r artifact/* "gh-pages/${SAFE_BRANCH}/" | |
| cd gh-pages | |
| git config user.name "github-actions[bot]" | |
| git config user.email \ | |
| "github-actions[bot]@users.noreply.github.com" | |
| git add "${SAFE_BRANCH}" | |
| git commit -m "Deploy PR preview for ${BRANCH_NAME}" || \ | |
| echo "No changes" | |
| git push | |
| cleanup-pr-preview: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
| steps: | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| - name: Remove PR preview | |
| run: | | |
| BRANCH_NAME="${{ github.head_ref }}" | |
| SAFE_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9-]/-/g') | |
| if [ -d "${SAFE_BRANCH}" ]; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email \ | |
| "github-actions[bot]@users.noreply.github.com" | |
| git rm -rf "${SAFE_BRANCH}" | |
| git commit -m "Remove PR preview for ${BRANCH_NAME}" | |
| git push | |
| fi | |
| comment-preview: | |
| runs-on: ubuntu-latest | |
| needs: deploy-pr-preview | |
| if: github.event_name == 'pull_request' && github.event.action != 'closed' | |
| steps: | |
| - name: Comment PR with preview info | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const repoOwner = context.repo.owner; | |
| const repoName = context.repo.repo; | |
| const branchName = context.payload.pull_request.head.ref; | |
| const safeBranch = | |
| branchName.replace(/[^a-zA-Z0-9-]/g, '-'); | |
| const baseUrl = | |
| `https://${repoOwner}.github.io/${repoName}`; | |
| const previewUrl = `${baseUrl}/${safeBranch}/`; | |
| const mainUrl = `${baseUrl}/`; | |
| const comment = `## 🚀 Example Site Preview Ready! | |
| The example site preview has been deployed for this PR. | |
| 🔗 **Preview URL:** ${previewUrl} | |
| ### Build Details | |
| - **Commit:** ${context.sha.substring(0, 7)} | |
| - **Branch:** ${branchName} | |
| - **Build Status:** ✅ Success | |
| Once this PR is merged, the changes will be live at: | |
| ${mainUrl} | |
| *Note: The preview will be automatically removed | |
| when this PR is closed.* | |
| `; | |
| // Find existing comment | |
| const { data: comments } = | |
| await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.login === 'github-actions[bot]' && | |
| comment.body.includes('Example Site Preview Ready') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: comment | |
| }); | |
| } |