Deploy frontend from artifact created by "Fix skipped not updating; fix old constraints lingering (#2659)" #3660
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
name: Deploy frontend from artifact | |
run-name: Deploy frontend from artifact created by "${{ github.event.workflow_run.display_title }}" | |
on: | |
workflow_run: | |
workflows: | |
- Build GO (WR) PR | |
- Build SRO PR | |
- Build ZO PR | |
- New Beta GO Release | |
- New Beta SRO Release | |
- New Beta ZO Release | |
- New ZO Release | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup variables | |
id: vars | |
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_var_name=$(cat frontend_build/repo_var_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 | |
- name: Checkout external gh-pages | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ vars[steps.vars.outputs.repo_var_name] }} | |
ssh-key: ${{ secrets[steps.vars.outputs.repo_deploy_secret_name] }} | |
ref: gh-pages | |
path: 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 (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: | |
max_attempts: 4 | |
timeout_minutes: 4 | |
command: | | |
cd gh-pages | |
git pull origin gh-pages | |
git push origin gh-pages | |
- name: Export url | |
id: export-url | |
# First line splits the full repo name (frzyc/genshin-optimizer) into $account (frzyc) and $repo (genshin-optimizer) | |
run: | | |
IFS=/ read -r account repo <<< ${{ vars[steps.vars.outputs.repo_var_name] }} | |
echo "url=Deployed ${{ steps.vars.outputs.ref }} to https://$account.github.io/$repo/${{ steps.vars.outputs.deployment_name }}/${{ steps.vars.outputs.frontend_name }} (Takes 3-5 minutes after this completes to be available)" >> $GITHUB_OUTPUT | |
- name: Output date | |
id: output-date2 | |
run: echo "date=$(date -u)" >> $GITHUB_OUTPUT | |
- name: Maintain comment | |
uses: actions-cool/maintain-one-comment@v3 | |
if: ${{ steps.vars.outputs.deployment_name != 'beta' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.vars.outputs.deployment_name }} | |
body: | | |
[${{ steps.vars.outputs.frontend_name }}] [${{ steps.output-date2.outputs.date }}] - ${{ steps.export-url.outputs.url }} | |
body-include: '<!-- Created by actions-cool/maintain-one-comment -->' | |
update-mode: 'append' |