Update main.yml #22
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
#original https://www.programonaut.com/how-to-deploy-a-git-repository-to-a-server-using-github-actions/ | |
name: Deploy to surge.sh | |
on: | |
push: | |
branches: [ "*" ] | |
pull_request: | |
branches: [ "*" ] | |
workflow_dispatch: | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
# Set it to the email address you use with Surge | |
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} | |
# SURGE_TOKEN: Set it to your login token (get it by doing a surge token) | |
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} | |
jobs: | |
Deploy-to-Surge: | |
name: Deploy | |
# The below code fixes the github queue. I dont know why | |
# https://stackoverflow.com/a/75072792 | |
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }} | |
# create a place to store your env.vars and secret.vars via https://github.com/ktsuttlemyre/kqDraft/settings/environments | |
environment: | |
name: ktsuttle-dev | |
url: ${{ vars.CNAME }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '14' | |
- run: | | |
echo "SURGE_LOGIN length: ${#SURGE_LOGIN}" | |
echo "CNAME: ${env.CNAME}" | |
if [[ -z "$SURGE_LOGIN" ]] || [[ -z "$SURGE_TOKEN" ]]; then | |
echo "Make sure SURGE_TOKEN and SURGE_LOGIN are set" | |
exit 1 | |
fi | |
npm install --global surge | |
surge . ${{ vars.CNAME }} |