Skip to content

Commit

Permalink
Fix feature deploy directory overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Nov 10, 2023
1 parent 0442f7b commit 5e6b88e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/feature-branch-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Create branch name without forward slashes
- name: Create branch name without text before first forward slash
run: |
RAW_BRANCH_NAME=${{ github.head_ref || github.ref_name }}
BRANCH_NAME=$(echo $RAW_BRANCH_NAME | sed 's/\//-/g')
BRANCH_NAME=$(echo $RAW_BRANCH_NAME | sed 's/[^/]*\///')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Checkout
Expand All @@ -29,7 +29,7 @@ jobs:

- name: Delete folder
run: |
git rm ${{ env.BRANCH_NAME }} -r
git rm demo-${{ env.BRANCH_NAME }} -r
git config user.name ${{ github.actor }}
git add .
git commit -m "Remove feature branch folder"
Expand All @@ -41,4 +41,4 @@ jobs:
with:
step: deactivate-env
token: ${{ secrets.GITHUB_TOKEN }}
env: staging-${{ env.BRANCH_NAME }}
env: demo-${{ env.BRANCH_NAME }}
14 changes: 7 additions & 7 deletions .github/workflows/feature-branch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Create branch name without forward slashes
- name: Create branch name without text before first forward slash
run: |
RAW_BRANCH_NAME=${{ github.head_ref || github.ref_name }}
BRANCH_NAME=$(echo $RAW_BRANCH_NAME | sed 's/\//-/g')
BRANCH_NAME=$(echo $RAW_BRANCH_NAME | sed 's/[^/]*\///')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Checkout
Expand All @@ -29,7 +29,7 @@ jobs:
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: staging-${{ env.BRANCH_NAME }}
env: demo-${{ env.BRANCH_NAME }}

- uses: actions/setup-node@v3
with:
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Build
env:
STORYBOOK_BUILD_PATH: ${{ env.BRANCH_NAME }}
STORYBOOK_BUILD_PATH: demo-${{ env.BRANCH_NAME }}
run: npm run build

- name: Create a version mark
Expand All @@ -67,12 +67,12 @@ jobs:
with:
branch: gh-pages
folder: temp-deploy-directory
target-folder: ${{ env.BRANCH_NAME }}
target-folder: demo-${{ env.BRANCH_NAME }}

- name: Wait for GitHub Pages to be deployed
uses: mydea/action-wait-for-api@v1
with:
url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.BRANCH_NAME }}/${{ github.sha }}.txt
url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/demo-${{ env.BRANCH_NAME }}/${{ github.sha }}.txt
expected-status: 200
timeout: 600
interval: 15
Expand All @@ -86,4 +86,4 @@ jobs:
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.BRANCH_NAME }}
env_url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/demo-${{ env.BRANCH_NAME }}
3 changes: 3 additions & 0 deletions .github/workflows/main-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ jobs:
with:
branch: gh-pages
folder: dist/storybook
# feature branch directories are prefixed with demo-*
# these are excluded from this action's default clean
clean-exclude: demo-*

0 comments on commit 5e6b88e

Please sign in to comment.