Skip to content

Commit

Permalink
Update to allow non-nested deployments (#2608)
Browse files Browse the repository at this point in the history
* Update to allow non-nested deployments

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Separate paths of nested/non-nested deployments

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
nguyentvan7 and coderabbitai[bot] authored Jan 25, 2025
1 parent 6cf874f commit 267a5aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ jobs:
run: yarn run nx run ${{inputs.frontend_name}}:build:production
- name: echos
run: |
touch frontend_name
echo ${{inputs.frontend_name}} > frontend_name
echo ${{inputs.deployment_name}} > deployment_name
echo ${{inputs.nested_deployments}} > nested_deployments
echo ${{inputs.repo_name}} > repo_name
echo ${{inputs.repo_deploy_secret_name}} > repo_deploy_secret_name
echo $(git rev-parse HEAD) > ref
- name: echos (frontend_name)
if: inputs.nested_deployments == 'true'
run: |
echo ${{inputs.frontend_name}} > frontend_name
- name: Archive build
uses: actions/upload-artifact@v4
with:
Expand All @@ -92,6 +89,7 @@ jobs:
dist/apps/${{inputs.frontend_name}}
frontend_name
deployment_name
nested_deployments
repo_name
repo_deploy_secret_name
ref
21 changes: 19 additions & 2 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run: |
echo "deployment_name=$(cat frontend_build/deployment_name)" >> $GITHUB_OUTPUT
echo "frontend_name=$(cat frontend_build/frontend_name)" >> $GITHUB_OUTPUT
echo "nested_deployments=$(cat frontend_build/nested_deployments)" >> $GITHUB_OUTPUT
echo "repo_name=$(cat frontend_build/repo_name)" >> $GITHUB_OUTPUT
echo "repo_deploy_secret_name=$(cat frontend_build/repo_deploy_secret_name)" >> $GITHUB_OUTPUT
echo "ref=$(cat frontend_build/ref)" >> $GITHUB_OUTPUT
Expand All @@ -40,19 +41,35 @@ jobs:
ssh-key: ${{ secrets[steps.vars.outputs.repo_deploy_secret_name] }}
ref: gh-pages
path: gh-pages
- name: Move to external gh-pages
- name: Move to external gh-pages (nested)
if: ${{ steps.vars.outputs.nested_deployments == 'true' }}
run: |
mkdir --parents "gh-pages/${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }}"
rm -rfv "gh-pages/${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }}" || true
mv "frontend_build/dist/apps/${{ steps.vars.outputs.frontend_name }}" "gh-pages/${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }}"
- name: Make commit to deploy
- name: Make commit to deploy (nested)
if: ${{ steps.vars.outputs.nested_deployments == 'true' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config pull.rebase false
git add ./${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }}
git commit --allow-empty -m "build ${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }} ${{ steps.vars.outputs.ref }}"
working-directory: gh-pages
- name: Move to external gh-pages (un-nested)
if: ${{ steps.vars.outputs.nested_deployments != 'true' }}
run: |
rm -rv "gh-pages/*" || true
mv "frontend_build/dist/apps/${{ steps.vars.outputs.frontend_name }}/*" "gh-pages"
- name: Make commit to deploy (un-nested)
if: ${{ steps.vars.outputs.nested_deployments != 'true' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config pull.rebase false
git add .
git commit --allow-empty -m "build ${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }} ${{ steps.vars.outputs.ref }}"
working-directory: gh-pages
- name: Push commit
uses: nick-fields/retry@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/new-zo-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
uses: ./.github/workflows/build-frontend.yml
with:
frontend_name: 'zzz-frontend'
deployment_name: '.'
deployment_name: ''
repo_name: ${{ vars.ZO_REPO}}
repo_deploy_secret_name: 'ZO_REPO_SSH_KEY'
show_dev_components: false
Expand Down

0 comments on commit 267a5aa

Please sign in to comment.