Skip to content

Deploy frontend from artifact created by "Build GO (WR) for 2473 - WIP: CharacterSelectionModal refactoring and followup changes for single selection" #2840

Deploy frontend from artifact created by "Build GO (WR) for 2473 - WIP: CharacterSelectionModal refactoring and followup changes for single selection"

Deploy frontend from artifact created by "Build GO (WR) for 2473 - WIP: CharacterSelectionModal refactoring and followup changes for single selection" #2840

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
- New Beta GO Release
- New Beta SRO 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 "ref=$(cat frontend_build/ref)" >> $GITHUB_OUTPUT
- name: Checkout external gh-pages
uses: actions/checkout@v4
with:
repository: ${{ vars.pr_repo }}
ssh-key: ${{ secrets.PR_REPO_SSH_KEY }}
ref: gh-pages
path: gh-pages
- name: Move to external gh-pages
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
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: 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.pr_repo }}
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'