Skip to content

Commit

Permalink
Merge branch 'develop' into feat/search-members
Browse files Browse the repository at this point in the history
  • Loading branch information
Spiral-Memory authored Dec 22, 2024
2 parents 01b59bf + 2a418cd commit 14b0430
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 64 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
LAYOUT_EDITOR_BASE_URL: "/EmbeddedChat/pulls/pr-${{github.event.pull_request.number}}/layout_editor"
DOCS_BASE_URL: "/EmbeddedChat/pulls/pr-${{github.event.pull_request.number}}/docs"
STORYBOOK_RC_HOST: "https://demo.qa.rocket.chat"

jobs:
build:
if: github.event.review.state == 'approved' && (github.event.review.author_association == 'COLLABORATOR' || github.event.review.author_association == 'OWNER')
Expand All @@ -22,15 +22,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Get user
run: echo "${{ github.event.pull_request.head.repo.owner.login }}" > user.txt

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: user
path: user.txt

- name: Setup Node.js
uses: actions/setup-node@v4
with:
Expand Down
58 changes: 4 additions & 54 deletions .github/workflows/deploy-pr.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,22 @@
name: Deploy PR-Preview

on:
workflow_run:
workflows: ["Build PR-Preview"]
types:
- completed

permissions:
contents: write
pages: write

jobs:
deploy:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: user
path: .
github-token: ${{github.token}}
repository: ${{github.repository}}
run-id: ${{github.event.workflow_run.id}}

- name: Get user
id: get_user
run: |
USER=$(cat user.txt)
echo "USER=$USER" >> $GITHUB_ENV
- name: Get Pull Request Number
id: get_pr_number
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/pulls?head=${{env.USER}}:${{ github.event.workflow_run.head_branch }}" \
| jq -r '.[0].number')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Check PR Approval Status
id: approval_check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=${{ env.PR_NUMBER }}
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews")
if ! echo "$RESPONSE" | jq . > /dev/null 2>&1; then
echo "Error: Invalid JSON response from GitHub API."
exit 1
fi
LATEST_REVIEW=$(echo "$RESPONSE" | jq 'sort_by(.submitted_at) | last')
STATE=$(echo "$LATEST_REVIEW" | jq -r '.state')
AUTHOR_ASSOCIATION=$(echo "$LATEST_REVIEW" | jq -r '.author_association')
echo "Latest review state: $STATE"
echo "Author association: $AUTHOR_ASSOCIATION"
if [ "$STATE" != "APPROVED" ] || { [ "$AUTHOR_ASSOCIATION" != "COLLABORATOR" ] && [ "$AUTHOR_ASSOCIATION" != "OWNER" ]; }; then
echo "The latest review is not an approved review from a collaborator or owner. Exiting."
exit 1
fi

steps:
- uses: actions/download-artifact@v4
if: success()
with:
name: github-pages
path: build/
Expand All @@ -74,7 +25,6 @@ jobs:
run-id: ${{github.event.workflow_run.id}}

- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-deploy
Expand Down

0 comments on commit 14b0430

Please sign in to comment.