feat: check pre-existing feed during feed import #855
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: Web App - PR Preview | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - "web-app/**" | |
| - "functions/**" | |
| - ".github/workflows/web-*.yml" | |
| jobs: | |
| deploy-web-app: | |
| uses: ./.github/workflows/web-app-deployer.yml | |
| with: | |
| FIREBASE_PROJECT: dev | |
| PREVIEW_DEPLOYMENT: true | |
| FEED_SUBMIT_GOOGLE_SHEET_ID: "1iXwux9hM4p5Li1EGgwx-8hU3sMDnF15yTflqmGjiZqE" | |
| OP_SLACK_WEBHOOK_URL: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/wm52iemzzm2cwfaoakwaufthuq/password" | |
| PREVIEW_HOST_NAME: "pr-${{ github.event.number }}" | |
| secrets: inherit | |
| update-pr-comment: | |
| name: Update PR comments | |
| runs-on: ubuntu-latest | |
| needs: [ deploy-web-app ] | |
| env: | |
| PR_ID: ${{ github.event.number }} | |
| steps: | |
| - name: Check for Existing Comment | |
| id: check-comment | |
| run: | | |
| HOSTING_URL_DECODED=$(echo "$HOSTING_URL_64" | base64 -d | sed 's/__firebase_project__/mobility-feeds-dev/g') | |
| COMMENT="Preview Firebase Hosting URL: $HOSTING_URL_DECODED" | |
| echo "PR comment: $COMMENT" | |
| COMMENTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/issues/${{ env.PR_ID }}/comments") | |
| JQ_CHECK=`echo "$COMMENTS" | jq -r ".[] | select(.body == \"$COMMENT\")"` | |
| if [ -z "$JQ_CHECK" ]; then | |
| echo "Comment does not exist." | |
| echo "comment_exists=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Comment already exists." | |
| echo "comment_exists=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| HOSTING_URL_64: ${{ needs.deploy-web-app.outputs.hosting_url }} | |
| - name: Comment on PR with Hosting URL (PR Preview) | |
| if: steps.check-comment.outputs.comment_exists == 'false' | |
| run: | | |
| HOSTING_URL_DECODED=$(echo "$HOSTING_URL_64" | base64 -d | sed 's/__firebase_project__/mobility-feeds-dev/g') | |
| COMMENT="Preview Firebase Hosting URL: $HOSTING_URL_DECODED" | |
| echo "$COMMENT" > comment.txt | |
| curl -d "{\"body\":\"$(cat comment.txt)\"}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -X POST "https://api.github.com/repos/${{ github.repository }}/issues/${{ env.PR_ID }}/comments" | |
| env: | |
| # Output is baseb4 encoded due to a false positive secret detection | |
| # More info https://github.com/orgs/community/discussions/37942 | |
| HOSTING_URL_64: ${{ needs.deploy-web-app.outputs.hosting_url }} | |