-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
inputs: | ||
tramline-input: | ||
required: false | ||
|
||
jobs: | ||
deploy_job: | ||
runs-on: ubuntu-latest | ||
name: A job to test tramline deploys | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Deploy | ||
uses: ./ # Uses the action in the root directory | ||
id: tramline | ||
with: | ||
input: ${{ github.event.inputs.tramline-input }} | ||
- name: Get the output | ||
run: | | ||
echo "vcode: ${{ steps.tramline.outputs.version_code }}" | ||
echo "vname: ${{ steps.tramline.outputs.version_name }}" | ||
echo "cref: ${{ steps.tramline.outputs.commit_ref }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Container image that runs your code | ||
FROM alpine:3.10 | ||
|
||
# Copies your code file from your action repository to the filesystem path `/` of the container | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
# Code file to execute when the docker container starts up (`entrypoint.sh`) | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# action.yml | ||
name: 'Configure Tramline' | ||
description: 'Checkout the correct ref & parse JSON inputs' | ||
inputs: | ||
input: | ||
description: "Input from Tramline as a JSON blob" | ||
required: true | ||
default: "{}" | ||
outputs: | ||
version_code: | ||
description: 'the version code (build number) for the build' | ||
value: ${{ steps.tramline.outputs.version_code }} | ||
version_name: | ||
description: 'the version name for the build' | ||
value: ${{ steps.tramline.outputs.version_name }} | ||
commit_ref: | ||
description: 'the commit for which this workflow is triggered' | ||
value: ${{ steps.tramline.outputs.commit_ref }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Parse inputs from Tramline | ||
run: ./parse_inputs.sh ${{ inputs.input }} | ||
id: tramline | ||
shell: bash | ||
|
||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.tramline.outputs.commit_ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash -l | ||
|
||
echo "Starting tramline input parsing..." | ||
|
||
# Install jq if it doesn't exist | ||
if ! command -v jq &> /dev/null | ||
then | ||
echo "jq is not installed. Installing..." | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
else | ||
echo "jq is already installed. Skipping..." | ||
fi | ||
|
||
# Parse JSON and store keys in an array | ||
echo $1 > tramline_input.json | ||
keys=() | ||
while read -r value | ||
do | ||
keys+=("$value") | ||
done < <(jq -c 'keys_unsorted[]' tramline_input.json) | ||
|
||
# Exit if there are parse errors | ||
if [ -z "$keys" ]; then | ||
echo "Error parsing Tramline inputs. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
# Loop through the keys and set variables | ||
for key in "${keys[@]}"; do | ||
# Get the value of the key from JSON | ||
value=$(jq -r ".$key" tramline_input.json) | ||
# Remove double quotes from key | ||
key="${key//\"/}" | ||
# Assign the value to a variable with a name based on the key | ||
output="${key}=${value}" | ||
# Output | ||
echo $output >> "$GITHUB_OUTPUT" | ||
done | ||
|
||
# Cleanup | ||
rm -f tramline_input.json | ||
echo "Finishing up tramline input parsing..." |