Skip to content

Commit

Permalink
Feature (ci): Add ./build.sh --env-file param to build from an `.en…
Browse files Browse the repository at this point in the history
…v` file (#125)

This makes it easier to run builds against a custom `.env` file.

Co-authored-by: leo <[email protected]>
Co-authored-by: joe <[email protected]>
  • Loading branch information
leojonathanoh and joeltimothyoh authored Mar 9, 2023
1 parent 759d260 commit 7fccc10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ jobs:
- uses: actions/checkout@v3
- name: Test build
run: |
set -a
. ./test/build-hlds-cstrike.env
./build.sh
./build.sh --env-file ./test/build-hlds-cstrike.env
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
- name: Test update
run: |
set -a
. ./test/update-hlds-cstrike.env
./build.sh
./build.sh --env-file ./test/update-hlds-cstrike.env
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
Expand All @@ -39,17 +35,13 @@ jobs:
- uses: actions/checkout@v3
- name: Test build
run: |
set -a
. ./test/build-srcds-hl2mp.env
./build.sh
./build.sh --env-file ./test/build-srcds-hl2mp.env
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
- name: Test update
run: |
set -a
. ./test/update-srcds-hl2mp.env
./build.sh
./build.sh --env-file ./test/update-srcds-hl2mp.env
env:
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
Expand Down
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@

############################# End of CI variables ##############################

# Get some options
while test $# -gt 0; do
case "$1" in
-f|--env-file)
shift
ENV_FILE=$1
shift
;;
esac
done

ENV_FILE=${ENV_FILE:-.env}
if [ -f "$ENV_FILE" ]; then
ENV_FILE="$( cd "$( dirname "$ENV_FILE" )" && pwd )/$( basename "$ENV_FILE" )"
echo "Reading env file $ENV_FILE"
. "$ENV_FILE"
fi

# Process user variables
REGISTRY_USER=${REGISTRY_USER:?err}
REGISTRY_PASSWORD=${REGISTRY_PASSWORD:?err}
Expand Down

0 comments on commit 7fccc10

Please sign in to comment.