linux-system-roles / firewall

Configure firewalld and system-config-firewall
https://linux-system-roles.github.io/firewall/
GNU General Public License v2.0
57 stars 32 forks source link

better way to get main branch [citest skip] #98

Closed richm closed 2 years ago

richm commented 2 years ago

The current version doesn't get the branch name in all cases: https://github.com/linux-system-roles/firewall/runs/7530456114?check_suite_focus=true

++ grep -o 'origin/HEAD -> origin/.*$'
++ git branch -r
++ awk -F/ '{print $3}'
+ _branch=
Error: Process completed with exit code 1.

This is because of the way that the checkout action works. If I use the same method as the checkout action:

git branch -r
  origin/main

so if this fails, try using git branch --points-at HEAD - this assumes the code is checked out to the main branch. If you look at the logs from the checkout action of https://github.com/linux-system-roles/firewall/runs/7530456114?check_suite_focus=true and https://github.com/linux-system-roles/metrics/runs/7440737046?check_suite_focus=true you can see that the code somehow has knowledge of the main branch - it knows to use "main" or "master" somehow. So my commit also includes some debugging - maybe we can use $GITHUB_REF or $GITHUB_REF_NAME

There's also the method that the checkout action uses - https://github.com/actions/checkout/blob/v2.4.2/src/git-command-manager.ts#L201 - where repositoryUrl comes from env $GITHUB_SERVER_URL/$GITHUB_REPOSITORY see https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables for the complete list of env. vars. available to a github action

nhosoi commented 2 years ago

richm closed this 18 minutes ago

May I ask why this pr was closed? Is it accidental?

richm commented 2 years ago

richm closed this 18 minutes ago

May I ask why this pr was closed? Is it accidental?

It is being replaced by https://github.com/linux-system-roles/firewall/pull/99