Merge pull request #1943 from dev-launchers/development/ideaspace #108
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-staging-apps | |
on: | |
push: | |
branches: | |
- 'staging/ideaspace' | |
- 'staging/ideaspace[1-2]' | |
- 'staging/recruitment' | |
- 'staging/recruitment[1-2]' | |
- 'staging/projects' | |
- 'staging/projects[1-2]' | |
- 'staging/website' | |
- 'staging/website[1-2]' | |
- 'staging/user-profile' | |
- 'staging/user-profile[1-2]' | |
- 'staging/gptbot' | |
- 'staging/gptbot[1-2]' | |
jobs: | |
Publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v3 | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | sed 's/staging\///')" >>$GITHUB_OUTPUT | |
id: extract_branch | |
- name: Setup node env 🏗 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/gallium | |
cache: 'yarn' | |
- name: Install dependencies 👨🏻💻 | |
run: yarn --frozen-lockfile --silent | |
- name: disable Image optimization | |
shell: bash | |
run: "sed -ie 's$unoptimized: false$unoptimized: true$g' ./apps/app/next.config.js" | |
- name: Change environment to the app specific subdomains | |
run: "sed -ie 's$https://staging.devlaunchers.org$https://${{ steps.extract_branch.outputs.branch }}.devlaunchers.org$g' ./apps/app/.env.staging" | |
- name: Change environment to staging | |
run: mv apps/app/.env.staging apps/app/.env.production | |
- name: generate css | |
run: yarn workspace @devlaunchers/tailwind build-tw | |
- name: Run build | |
run: yarn workspace @devlaunchers/app build | |
- name: Export | |
run: yarn workspace @devlaunchers/app export | |
- name: Publish | |
if: ${{ !env.ACT }} | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: "b0eb1f5510cb71344976cb9cac51e2af" | |
projectName: ${{ steps.extract_branch.outputs.branch }} | |
directory: ./apps/app/out | |
branch: main | |
#I think this needs a bit of explanation. | |
#I'm extracting the branch name and modifying it to only show what comes after staging/ | |
#for example: if this action was triggered on staging/ideaspace the modified string becomes 'ideaspace'. | |
#I'm doing this because in cloudflare pages dashboard I created these projects | |
#- 'ideaspace' => ideaspace.pages.dev | |
#- 'ideaspace1' => ideaspace1.pages.dev | |
#- 'ideaspace2' => ideaspace2.pages.dev | |
#- 'recruitment' => recruitment-djw.pages.dev | |
#- 'recruitment1' => recruitment1.pages.dev | |
#- 'recruitment2' => recruitment2.pages.dev | |
#- 'projects' => projects-2w7.pages.dev | |
#- 'projects1' => projects1-1ut.pages.dev | |
#- 'projects2' => projects2.pages.dev | |
#- 'website' => website-386.pages.dev | |
#- 'website1' => website1-c59.pages.dev | |
#- 'website2' => website2-7s8.pages.dev | |
#- 'user-profile' => user-profile-4zw.pages.dev | |
#- 'user-profile1' => user-profile1.pages.dev | |
#- 'user-profile2' => user-profile2.pages.dev | |
#and on every commit that touches the branches of these teams I deploy to the app from the branch name extraction step: Extract branch name |