Skip to content

Commit

Permalink
Fix issue with regex check + missing outputs in v2.6.0 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids authored Nov 2, 2022
1 parent b36a3d2 commit 6f946b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ on:
description: "Uffizzi Preview Expiration Interval in Seconds"
value: ${{ jobs.uffizzi-preview.outputs.expiration_interval }}
expiration:
description: "Uffizzi Preview Expiration Timestamp String"
description: "Uffizzi Preview Expiration Time String"
value: ${{ jobs.uffizzi-preview.outputs.expiration }}
expiration_timestamp:
description: "Uffizzi Preview Expiration UNIX Timestamp"
value: ${{ jobs.uffizzi-preview.outputs.expiration_timestamp }}

permissions:
contents: read
Expand All @@ -121,6 +124,7 @@ jobs:
containers_uri: ${{ steps.outputs.outputs.containers_uri }}
expiration_interval: ${{ steps.outputs.outputs.expiration_interval }}
expiration: ${{ steps.outputs.outputs.expiration }}
expiration_timestamp: ${{ steps.outputs.outputs.expiration_timestamp }}
steps:
- name: DEBUG - Dump GitHub context and environment info
if: ${{ runner.debug }}
Expand Down Expand Up @@ -328,20 +332,29 @@ jobs:
echo "OUTPUT_URL=$OUTPUT_URL" >> $GITHUB_ENV
echo "OUTPUT_CONTAINERS=$OUTPUT_CONTAINERS" >> $GITHUB_ENV
export EXPIRATION_HOURS=$(grep --perl-regexp --only-matching 'delete_preview_after: \K\d+' ${{ inputs.compose-file-cache-path }})
export EXPIRATION_HOURS=$(grep --perl-regexp --only-matching '^[ \t]*(?!#)delete_preview_after: \K\d+' ${{ inputs.compose-file-cache-path }})
if [ -z "$EXPIRATION_HOURS" ]
then
echo "No preview expiration parameter found."
else
export EXPIRATION_INTERVAL=$(( $EXPIRATION_HOURS * 3600 ))
export EXPIRATION=$(date --utc --date=@$(($(date +'%s') + $EXPIRATION_INTERVAL)))
export EXPIRATION_TIMESTAMP=$(date +'%s')
export EXPIRATION=$(date --utc --date=@$(($EXPIRATION_TIMESTAMP + $EXPIRATION_INTERVAL)))
echo "Expiring in $EXPIRATION_INTERVAL seconds at $EXPIRATION."
echo "EXPIRATION_INTERVAL=$EXPIRATION_INTERVAL" >> $GITHUB_ENV
echo "EXPIRATION=This Preview will be destroyed in $EXPIRATION_HOURS hours at: $EXPIRATION" >> $GITHUB_ENV
echo "EXPIRATION=:alarm_clock: This Preview will be destroyed in $EXPIRATION_HOURS hours at: $EXPIRATION" >> $GITHUB_ENV
fi
# Expose the step output variables
echo "url=$OUTPUT_URL" >> $GITHUB_OUTPUT
echo "id=$OUTPUT_ID" >> $GITHUB_OUTPUT
echo "containers_uri=$OUTPUT_CONTAINERS" >> $GITHUB_OUTPUT
echo "expiration_interval=$EXPIRATION_INTERVAL" >> $GITHUB_OUTPUT
echo "expiration=$EXPIRATION" >> $GITHUB_OUTPUT
echo "expiration_timestamp=$EXPIRATION_TIMESTAMP" >> $GITHUB_OUTPUT
- name: Create or Update Comment with Deployment URL
uses: peter-evans/create-or-update-comment@v2
if: ${{ inputs.compose-file-cache-key != '' }}
Expand All @@ -355,7 +368,7 @@ jobs:
:page_facing_up: [View Application Logs etc.](${{ env.OUTPUT_CONTAINERS }})
:alarm_clock: ${{ env.EXPIRATION }}
${{ env.EXPIRATION }}
What is Uffizzi? [Learn more](https://github.com/UffizziCloud/uffizzi)
edit-mode: replace
6 changes: 6 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ outputs:
description: 'ID of preview for later reference'
containers_uri:
description: 'URI to the deployment details'
expiration_interval:
description: "Expiration interval in seconds"
expiration:
description: 'Expiration as a string'
expiration_timestamp:
description: 'Expiration as a UNIX timestamp'
runs:
using: 'docker'
image: 'docker://uffizzi/cli:v1'
Expand Down

0 comments on commit 6f946b7

Please sign in to comment.