diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8c3a71c..6cf8204 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,6 @@ on: branches: - 'master' - 'main' - - 'staging' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml new file mode 100644 index 0000000..4434890 --- /dev/null +++ b/.github/workflows/staging.yaml @@ -0,0 +1,40 @@ +name: Staging +on: + push: + branches: + - 'staging' + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + +jobs: + publish: + runs-on: ubuntu-20.04 + name: Publish + environment: staging + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Prepare repository + run: git fetch --unshallow --tags + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + + - name: Install dependencies + run: | + yarn -v + yarn install --immutable + + - name: Build + run: export DEFAULT_BRANCH=staging;yarn run build + + - name: Create Release + run: yarn auto shipit -v diff --git a/core/create-app.tsx b/core/create-app.tsx index 82eca8e..dc5a9bb 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -90,7 +90,10 @@ export async function createApp(config: CreateMagicAppConfig) { }; const templateFlags: any = await parseFlags(mapTemplateToFlags(config.template as string), config?.data); - const repoUrl = new URL(`${DEFAULT_CREATE_MAGIC_APP_REPO}/tree/${config.branch}`, GITHUB_BASE_URL); + const repoUrl = new URL( + `${DEFAULT_CREATE_MAGIC_APP_REPO}/tree/${process.env.DEFAULT_BRANCH ?? config.branch}`, + GITHUB_BASE_URL, + ); const repoInfo = await getRepoInfo(repoUrl, getRelativeTemplatePath(config.template as string)); if (repoInfo) { const templatePath = getAbsoluteTemplatePath(config.template as string);