Skip to content

Commit

Permalink
Add a global environment to work across (dependent) actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
marceltaeumel committed Sep 25, 2021
1 parent 8b730ce commit 41d5fd6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
tmp/*.image
tmp/*.changes
- name: Export global environment
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.smalltalk }}-env
path: tmp/global-env


test-image:
needs: [prepare-image]
Expand All @@ -76,6 +82,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Import global environment
uses: actions/download-artifact@v2
with:
name: ${{ matrix.smalltalk }}-env
path: tmp

- name: Download artifacts
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -120,12 +132,18 @@ jobs:
name: 📦 Prepare bundles for ${{ matrix.smalltalk }}
env:
SMALLTALK_VERSION: ${{ matrix.smalltalk }}
SHOULD_DEPLOY: endsWith(github.ref, "squeak-trunk")
SHOULD_CODESIGN: env.SHOULD_DEPLOY
SHOULD_DEPLOY: ${{ endsWith(github.ref, 'squeak-trunk') }}
SHOULD_CODESIGN: ${{ endsWith(github.ref, 'squeak-trunk') }}

steps:
- uses: actions/checkout@v2

- name: Import global environment
uses: actions/download-artifact@v2
with:
name: ${{ matrix.smalltalk }}-env
path: tmp

- name: Download artifacts
uses: actions/download-artifact@v2
with:
Expand All @@ -148,7 +166,7 @@ jobs:
path: product/*

- run: ./deploy_bundles.sh
if: env.SHOULD_DEPLOY
if: env.SHOULD_DEPLOY == 'true'
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_IV: ${{ secrets.DEPLOY_IV }}
Expand Down
13 changes: 13 additions & 0 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,20 @@ export_variable() {
local var_value=$2
if [[ ! -z ${GITHUB_ENV} ]]; then
echo "${var_name}=${var_value}" >> $GITHUB_ENV
echo "${var_name}=${var_value}" >> $GLOBAL_ENV
else
print_warning "...skipping export of $var_name outside GitHub Actions..."
fi
}

import_variables() {
if is_file $GLOBAL_ENV; then
source $GLOBAL_ENV
else
echo "No global variables to import."
fi
}

prepare_platform_vm() {
case $RUNNER_OS in
"Windows")
Expand Down Expand Up @@ -161,6 +170,10 @@ readonly PRODUCT_PATH="${HOME_PATH}/product"
readonly TMP_PATH="${HOME_PATH}/tmp"
mkdir -p "${BUILD_PATH}" "${PRODUCT_PATH}" "${TMP_PATH}"

# Communicate variables beyond a single action
readonly GLOBAL_ENV="${TMP_PATH}/global-env"
import_variables

# Assure $RUNNER_OS if not invoked from within GitHub Actions
if [[ -z "${RUNNER_OS}" ]]; then
case $(uname -s) in
Expand Down
8 changes: 4 additions & 4 deletions prepare_bundles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@

set -o errexit

source "env_vars"
source "helpers.sh"
source "helpers_bundles.sh"

[[ -z "${SMALLTALK_VERSION}" ]] && exit 2
[[ -z "${SHOULD_CODESIGN}" ]] && exit 3

[[ -z "${SQUEAK_VERSION}" ]] && exit 4
[[ -z "${SQUEAK_UPDATE}" ]] && exit 5
[[ -z "${IMAGE_BITS}" ]] && exit 6

source "env_vars"
source "helpers.sh"
source "helpers_bundles.sh"

readonly TEMPLATE_PATH="${HOME_PATH}/templates"
readonly AIO_TEMPLATE_PATH="${TEMPLATE_PATH}/all-in-one"
readonly LIN_TEMPLATE_PATH="${TEMPLATE_PATH}/linux"
Expand Down
6 changes: 3 additions & 3 deletions test_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

set -o errexit

[[ -z "${SMALLTALK_VERSION}" ]] && exit 2
[[ -z "${SMALLTALK_CI_HOME}" ]] && exit 3

source "env_vars"
source "helpers.sh"

[[ -z "${SMALLTALK_VERSION}" ]] && exit 2
[[ -z "${SMALLTALK_CI_HOME}" ]] && exit 3

readonly SCI_PATH="${HOME_PATH}/smalltalk-ci"

test_image() {
Expand Down

0 comments on commit 41d5fd6

Please sign in to comment.