s0 / git-publish-subdir-action

GitHub Action to push a subdirectory as a branch to any git repo (e.g. for GitHub Pages)
https://github.com/marketplace/actions/push-git-subdirectory-as-branch
MIT License
208 stars 36 forks source link

CRIT: autoselect a main branch #90

Closed eXponenta closed 1 year ago

eXponenta commented 1 year ago

Critical bug. If something will with target branch, automatically will selected a 'main'

This is forbidden beckhaviour, task SHOULD CRASH in this case.

image

s0 commented 1 year ago

Hi @eXponenta,

Could you share the config for this step from your workflow yaml file that runs this?

Cheers, Sam.

eXponenta commented 1 year ago

@s0

This is my miss that revealed this critical

config:

name: Update VR Template after build
on:
  workflow_run:
    workflows: [Build]
    types:
      - completed
env:
  FROM_BRANCH: main
  FROM_FOLDER: dist.s3
  TARGET_REPO:  <secret>//
  TARGET_BRACH: master-test
  TARGE_FOLDER: webxr.new
jobs:
  update:
    name: Deploy in template
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        ref: ${{ env.FROM_BRANCH }}
    - name: Set Git config
      run: |
        git config --local user.email "actions@github.com"
        git config --local user.name "Github Actions"
    - name: Deploy
      uses: s0/git-publish-subdir-action@develop
      env:
        REPO: ${{ env.TARGET_REPO }}
        BRANCH: ${{ env.TARGET_BRACH }} # <<-- was a FROM_BRANCH, i did a miss 
        FOLDER: ${{ env.FROM_FOLDER }}
        TARGET_DIR: ${{ env.TARGE_FOLDER }}
        SKIP_EMPTY_COMMITS: true
        MESSAGE: Auto generated commit
        SSH_PRIVATE_KEY: ${{ secrets.VR_PLAYER_DEPLOY }}
        KNOWN_HOSTS_FILE: .github/known_hosts # Path relative to the root of the repository

I think this is undefined behaviour, when we push to specific branch that not exist and should stop task