-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #383 from adobe/sonarCloudGithubActions
build: move storybook upload to post-build
- Loading branch information
Showing
2 changed files
with
95 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,62 +34,63 @@ jobs: | |
- name: Test 🧪 | ||
run: yarn test | ||
|
||
- name: Upload code coverage | ||
- name: Build 🛠️ | ||
run: yarn build | ||
|
||
- name: Build Storybook | ||
run: yarn build:storybook | ||
|
||
- name: Upload code coverage and storybook | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: rsc-code-coverage | ||
path: | | ||
coverage/lcov.info | ||
test-report.xml | ||
dist-storybook/* | ||
- name: Build 🛠️ | ||
run: yarn build | ||
|
||
- name: Build Storybook | ||
run: yarn build:storybook | ||
|
||
- name: Create and Upload Storybook to PR directory | ||
run: | | ||
PR_NUMBER="PR-${{ github.event.number }}" | ||
# - name: Create and Upload Storybook to PR directory | ||
# run: | | ||
# PR_NUMBER="PR-${{ github.event.number }}" | ||
|
||
git config user.name "evargast" | ||
git config user.email "[email protected]" | ||
# git config user.name "evargast" | ||
# git config user.email "[email protected]" | ||
|
||
# Fetch the existing gh-pages branch | ||
git fetch origin gh-pages | ||
# # Fetch the existing gh-pages branch | ||
# git fetch origin gh-pages | ||
|
||
# Checkout the existing gh-pages branch | ||
git checkout gh-pages | ||
# # Checkout the existing gh-pages branch | ||
# git checkout gh-pages | ||
|
||
# Remove the PR directory if it exists | ||
rm -rf "${PR_NUMBER}" | ||
# # Remove the PR directory if it exists | ||
# rm -rf "${PR_NUMBER}" | ||
|
||
# Create the PR directory | ||
mkdir "${PR_NUMBER}" | ||
# # Create the PR directory | ||
# mkdir "${PR_NUMBER}" | ||
|
||
# Copy the contents of dist-storybook to the directory | ||
cp -r dist-storybook/* "${PR_NUMBER}/" | ||
# # Copy the contents of dist-storybook to the directory | ||
# cp -r dist-storybook/* "${PR_NUMBER}/" | ||
|
||
rm -rf node_modules # Explicitly remove the node_modules directory | ||
rm -rf dist-storybook # Explicitly remove the dist-storybook directory | ||
# rm -rf node_modules # Explicitly remove the node_modules directory | ||
# rm -rf dist-storybook # Explicitly remove the dist-storybook directory | ||
|
||
# Add, commit, and push changes | ||
git add "${PR_NUMBER}/." | ||
git commit -m "Update Storybook for ${PR_NUMBER}" | ||
git push -f origin gh-pages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# # Add, commit, and push changes | ||
# git add "${PR_NUMBER}/." | ||
# git commit -m "Update Storybook for ${PR_NUMBER}" | ||
# git push -f origin gh-pages | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Add comment to the PR with Storybook URL | ||
run: | | ||
PR_NUMBER="${{ github.event.number }}" | ||
COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}" | ||
# - name: Add comment to the PR with Storybook URL | ||
# run: | | ||
# PR_NUMBER="${{ github.event.number }}" | ||
# COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}" | ||
|
||
curl -sSL \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-X POST \ | ||
-d '{"body":"'"${COMMENT_BODY}"'"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | ||
# curl -sSL \ | ||
# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
# -X POST \ | ||
# -d '{"body":"'"${COMMENT_BODY}"'"}' \ | ||
# "https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
name: Sonar | ||
name: PR Post-Build | ||
on: | ||
workflow_run: | ||
workflows: [PR Build] | ||
types: [completed] | ||
jobs: | ||
sonar: | ||
name: Sonar | ||
post-build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
if: github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout main | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.workflow_run.head_repository.full_name }} | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
fetch-depth: 0 | ||
|
||
- name: 'Download code coverage' | ||
uses: actions/github-script@v6 | ||
with: | ||
|
@@ -35,8 +36,10 @@ jobs: | |
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/rsc-code-coverage.zip`, Buffer.from(download.data)); | ||
- name: 'Unzip code coverage' | ||
run: unzip rsc-code-coverage.zip | ||
|
||
- name: SonarCloud Scan | ||
uses: sonarsource/sonarcloud-github-action@master | ||
env: | ||
|
@@ -48,3 +51,49 @@ jobs: | |
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }} | ||
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }} | ||
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }} | ||
- name: Create and Upload Storybook to PR directory | ||
run: | | ||
PR_NUMBER="PR-${{ github.event.workflow_run.pull_requests[0].number }}" | ||
git config user.name "evargast" | ||
git config user.email "[email protected]" | ||
# Fetch the existing gh-pages branch | ||
git fetch origin gh-pages | ||
# Checkout the existing gh-pages branch | ||
git checkout gh-pages | ||
# Remove the PR directory if it exists | ||
rm -rf "${PR_NUMBER}" | ||
# Create the PR directory | ||
mkdir "${PR_NUMBER}" | ||
# Copy the contents of dist-storybook to the directory | ||
cp -r dist-storybook/* "${PR_NUMBER}/" | ||
rm -rf node_modules # Explicitly remove the node_modules directory | ||
rm -rf dist-storybook # Explicitly remove the dist-storybook directory | ||
# Add, commit, and push changes | ||
git add "${PR_NUMBER}/." | ||
git commit -m "Update Storybook for ${PR_NUMBER}" | ||
git push -f origin gh-pages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Add comment to the PR with Storybook URL | ||
run: | | ||
PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" | ||
COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}" | ||
curl -sSL \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-X POST \ | ||
-d '{"body":"'"${COMMENT_BODY}"'"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |