Skip to content

Commit

Permalink
Improve GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yorevs committed Aug 22, 2024
1 parent b6ed500 commit 7cd394f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
50 changes: 40 additions & 10 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ on:
type: boolean
push:
branches:
- '**'
- 'master'
paths:
- 'bin/**'
- 'dotfiles/**'
- 'tests/**'
- '*.bash'
- '**/*.bash'
fork:
branches:
- '**'
Expand All @@ -32,7 +32,7 @@ on:
- 'bin/**'
- 'dotfiles/**'
- 'tests/**'
- '*.bash'
- '**/*.bash'

permissions:
contents: write
Expand All @@ -41,11 +41,40 @@ env:
JOB_NAME: "HomeSetup-Build"

jobs:
set-os-matrix:
runs-on: "ubuntu-latest"
outputs:
matrix-os: ${{ steps.set-matrix-items.outputs.matrix-os }}
steps:
- name: Show Selected Input
run: |
echo "Build on Ubuntu-Latest: ${{ inputs.ubuntu || false }}"
echo "Build on MacOS-Latest: ${{ inputs.macos || false }}"
- name: Set Inclusion Matrix
id: set-matrix-items
run: |
JSON=""
if [[ "${{ inputs.ubuntu }}" == "true" ]]; then
JSON="\"ubuntu-latest\""
fi
if [[ "${{ inputs.macos }}" == "true" ]]; then
[[ -n "$JSON" ]] && JSON="${JSON}, "
JSON="${JSON} \"macos-latest\""
fi
[[ -z "${JSON}" ]] && JSON="\"ubuntu-latest\""
JSON="[${JSON}]"
echo "JSON: ${JSON}"
echo "matrix-os=$( echo "${JSON}" )" >> $GITHUB_OUTPUT
build:
runs-on: 'ubuntu-latest'
needs: set-os-matrix
strategy:
matrix:
os: ${{ fromJson(needs.set-os-matrix.outputs.matrix-os) }}
runs-on: ${{ matrix.os }}
env:
HHS_LOG_DIR: '/Users/runner/.hhs/log'
HHS_PREFIX: "${{ github.workspace }}"
HHS_LOG_DIR: "${HOME}/.hhs/log"
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -58,12 +87,13 @@ jobs:
run: pip install --upgrade pip
- name: Install HomeSetup with Prefix
run: |
if ./install.bash -r -p "${{ github.workspace }}"; then
echo "${{ github.workspace }}" > "${HOME}/.hhs-prefix"
if ./install.bash -r -p "${HHS_PREFIX}"; then
echo "${HHS_PREFIX}" > "${HOME}/.hhs-prefix"
echo -e "\nInstallation information:"
echo -e "SHELL: ${SHELL}"
echo -e " HOME: ${HOME}"
echo -e " USER: ${USER}\n"
echo -e " SHELL: ${SHELL}"
echo -e "PREFIX: ${HHS_PREFIX}"
echo -e " HOME: ${HOME}"
echo -e " USER: ${USER}\n"
echo -en "Loading bash profile..."
if source "${HOME}"/.bashrc; then echo "OK"; else echo "FAILED"; fi
echo "HHS_LOG_DIR=$(echo ${HHS_LOG_DIR})" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion dotfiles/aliasdef
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if __hhs_has 'ifconfig'; then
__hhs_alias my-ip='__hhs_ip external'
__hhs_alias vpn-ip='__hhs_ip vpn'
__hhs_alias ip-info='__hhs_ip_info'
__hhs_alias ipi="__hhs_ip_info $(my-ip | awk '{print $3}') || echo \"${YELLOW}Not connected to the internet${NC}\""
__hhs_alias ipi="__hhs_ip_info $(__hhs_ip external | awk '{print $3}') || echo \"${YELLOW}Not connected to the internet${NC}\""
__hhs_alias ip-lookup='__hhs_ip_lookup'
__hhs_alias ip-resolve='__hhs_ip_resolve'
fi
Expand Down
2 changes: 1 addition & 1 deletion install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Usage: $APP_NAME [OPTIONS] <args>
else
echo -en "${WHITE}Copying: ${BLUE} ${src_file} -> ${dest_file}... "
\rsync --archive "${src_file}" "${dest_file}"
\chown "${USER}":"${GROUP}" "${dest_file}"
\chown "${USER}":"${GROUP}" "${dest_file}" &>/dev/null
[[ -f "${dest_file}" ]] && echo -e "${GREEN}OK${NC}"
[[ -f "${dest_file}" ]] || echo -e "${RED}FAILED${NC}"
fi
Expand Down

0 comments on commit 7cd394f

Please sign in to comment.