Skip to content

Commit

Permalink
Create .env file in workflow for secure environment variable setup
Browse files Browse the repository at this point in the history
- Add a step to generate a default .env file if missing, setting default values for PLUGIN_DIR, WP_LATEST_TESTS_DIR, PHPUNIT_DIR, GF_PLUGIN_DIR, and GH_AUTH_TOKEN.
- GH_AUTH_TOKEN is securely injected from GitHub Secrets.
- This ensures consistent behavior between CI environments without exposing the token externally.
  • Loading branch information
zackkatz committed Feb 17, 2025
1 parent 82377bf commit 2791c99
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4

- name: Create .env file if missing
run: |
if [ ! -f .env ]; then
echo "PLUGIN_DIR=$HOME" > .env
echo "WP_LATEST_TESTS_DIR=./wordpress-latest-tests-lib" >> .env
echo "PHPUNIT_DIR=./phpunit" >> .env
echo "GF_PLUGIN_DIR=./gravityforms" >> .env
echo "GH_AUTH_TOKEN=${{ secrets.GH_ACCESS_TOKEN }}" >> .env
fi
- name: Install Docker Compose
run: |
sudo apt-get update
Expand All @@ -30,9 +40,6 @@ jobs:
- name: Clone GV Tooling
run: gh repo clone GravityKit/Tooling $HOME/tooling

- name: Set Executable Permissions on Docker Unit Tests Directory
run: chmod -R +x $HOME/tooling/docker-unit-tests

- name: Authenticate GitHub for Composer
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
Expand Down Expand Up @@ -61,7 +68,7 @@ jobs:
- name: Configure Test Environment
env:
GH_AUTH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
run: $HOME/tooling/docker-unit-tests/docker-unit-tests.sh prepare_all
run: bash $HOME/tooling/docker-unit-tests/docker-unit-tests.sh prepare_all

# Consolidate workspace files into a single directory for upload
- name: Prepare Workspace Artifact
Expand Down

0 comments on commit 2791c99

Please sign in to comment.