Skip to content

[Build & Deploy] feature/issue_116 #50

[Build & Deploy] feature/issue_116

[Build & Deploy] feature/issue_116 #50

name: "[Manual] Build & Deploy"
run-name: "[Build & Deploy] ${{ github.ref_name }}"
on:
workflow_dispatch: {}
push:
branches:
- main
- develop
jobs:
get_env_name:
name: PreTask
uses: ./.github/workflows/oncall_get_env_name.yaml
format_code:
if: ${{ github.head_ref != 'develop' || github.head_ref != 'main' || !github.head_ref != 'hotfix' }}
name: PreTask
uses: ./.github/workflows/oncall_format_astro_code.yaml
permissions:
actions: write
checks: write
contents: write
deploy_frontend:
if: ${{ ! failure() }}
needs: ["get_env_name", "format_code"]
environment:
name: ${{ needs.get_env_name.outputs.env_name }}
url: ${{ steps.published.outputs.pageurl }}
runs-on: ubuntu-latest
name: Build & Deploy
env:
PROJECT_NAME: skyshare
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.ref_name }}
- name: Build
shell: bash
run: |
echo "Commit: $(git show --format='%H' --no-patch)"
echo "Node Version: $(node --version)"
npm install && npm run build
working-directory: ./astro
env:
PUBLIC_CREATEPAGES_ENDPOINT: ${{ secrets.PUBLIC_CREATEPAGES_ENDPOINT }}
PUBLIC_DELETEPAGE_ENDPOINT: ${{ secrets.PUBLIC_DELETEPAGE_ENDPOINT }}
PUBLIC_GETPAGES_ENDPOINT: ${{ secrets.PUBLIC_GETPAGES_ENDPOINT }}
PUBLIC_IS_NOT_PRODUCTION: ${{ vars.PUBLIC_IS_NOT_PRODUCTION }}
- name: Publish to Cloudflare Pages
id: publish
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./astro/dist --commit-dirty=true --project-name=${{ env.PROJECT_NAME }}
## cloudflare pagesのURLは28文字以上にならない
- name: Post publish
id: published
shell: bash
run: |
REF_NAME_ESCAPED=`echo '${{ github.ref_name }}' | sed -E 's/[//_/.]/-/g' | sed -E 's/(.{,28}).*/\1/' | sed -E 's/-*$//'`;
if [[ "${REF_NAME_ESCAPED}" == "${{ github.event.repository.default_branch }}" ]];then
REF_NAME_ESCAPED=""
else
REF_NAME_ESCAPED="${REF_NAME_ESCAPED}."
fi
echo "pageurl=https://${REF_NAME_ESCAPED}${{ env.PROJECT_NAME }}.pages.dev/" >> $GITHUB_OUTPUT