I'm new to Github Action and Workflow.
My repository is a private one, and I want to host Github Page from that repository. So I build my app bundle and cd
on it, initiating a new repository whose remote origin is same as the original one(Actually this is a recommended way to deploy on Github Page). I tried to make an orphan branch(gh-pages
) and pushed it, resulting in the following error:
fatal: could not read Username for 'https://github.com/': No such device or address
Here is a total Github workflow yaml below:
name: Build and Deploy on Github Page
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
setup-build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout to ${{ github.ref }} branch ️
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Generate .env ⚙️
run: |
echo "_PAGE_TITLE=\"${{ vars._PAGE_TITLE }}\"" >> .env
echo "_PAGE_DESCRIPTION=\"${{ vars._PAGE_DESCRIPTION }}\"" >> .env
echo "_PAGE_URL=\"${{ vars._PAGE_URL }}\"" >> .env
echo "_REPO_NAME=\"${{ vars._REPO_NAME }}\"" >> .env
- name: Install app
run: yarn install # yarn install
- name: Setup Git Identity
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
# git config --global credential.helper cache # works same whether or not
- name: Build and Deploy
run: sh gh-deploy.sh
# gh-deploy.sh
#!/usr/bin/env sh
# https://vitejs.dev/guide/static-deploy.html
set -e
yarn build
cd dist
echo > .nojekyll
git init
git checkout -B main
git add -A
git commit -m 'github page deploy'
# same as the repository which started the github action
git remote add origin https://github.com/cadenzah/xxxxx.git
git push -f origin main:gh-pages
cd ..
rm -rf dist
I wonder what is wrong with my configuration. Is it the issue with credential(PAT)?
EDIT: Isn't there any way to share the original credentials from actions/checkout on other directory(in which additional git(hub) repository is)?