Skip to content

Commit 75c8d7e

Browse files
authored
Replace deprecated set output command (wpengine#18)
Replaces the need to use the deprecated set-output command in our post-deploy script. Instead of setting an output, we'll write a status file that the next step can retrieve using an HTTP request.
1 parent 8e2580b commit 75c8d7e

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

.github/workflows/e2e-deploy.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ on:
1313
jobs:
1414
run_action:
1515
runs-on: ubuntu-latest
16-
outputs:
17-
status: ${{ steps.deploy.outputs.status }}
18-
steps:
16+
steps:
1917
- uses: actions/checkout@v3
2018
- name: Bump test plugin version number
2119
run: sed -i 's/0.0.1/0.0.2/' tests/data/plugins/test-plugin/test-plugin.php
2220
- name: Deploy to WP Engine
23-
id: deploy
2421
uses: ./.github/actions/deploy
2522
with:
2623
# Deploy vars
@@ -33,16 +30,21 @@ jobs:
3330
FLAGS: '-r --backup --backup-dir=/tmp --itemize-changes'
3431
SCRIPT: "tests/data/post-deploy/test-plugin.sh"
3532
CACHE_CLEAR: true
36-
validate_result:
33+
- name: Fetch deploy results
34+
id: fetchResult
35+
uses: fjogeleit/http-request-action@v1
36+
with:
37+
url: "https://sitedeploye2e.wpengine.com/wp-content/plugins/test-plugin/status.json"
38+
- name: Validate deploy results
39+
run: |
40+
[ ${{ fromJson(steps.fetchResult.outputs.response).status }} = "success" ] || exit 1
41+
notify:
3742
runs-on: ubuntu-latest
3843
if: ${{ !cancelled() }}
3944
needs: run_action
4045
steps:
41-
- name: Validate deploy results
42-
run: |
43-
[ ${{needs.run_action.outputs.status}} = "pass" ] || exit 1
4446
- name: Notify slack on failure
45-
if: failure() && github.ref == 'refs/heads/main'
47+
if: needs.run_action.result == 'failure' && github.ref == 'refs/heads/main'
4648
env:
4749
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
4850
uses: voxmedia/github-action-slack-notify-build@v1

tests/data/post-deploy/test-plugin.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
BACKUP_DIR=/tmp
44
PLUGINS_DIR=wp-content/plugins
55
PLUGIN_NAME=test-plugin
6+
STATUS_FILE=status.json
67

78
cleanup() {
89
rm tests/data/post-deploy/test-plugin.sh
@@ -26,8 +27,8 @@ echo "Old test plugin version: $BEFORE_PLUGIN_VERSION"
2627
# Check that the expected update was made
2728
if [ -z "$BEFORE_PLUGIN_VERSION" ] || [ -z "$AFTER_PLUGIN_VERSION" ] || [ "$BEFORE_PLUGIN_VERSION" = "$AFTER_PLUGIN_VERSION" ]; then
2829
echo "Failure: Test plugin was not updated!"
29-
echo "::set-output name=status::fail"
30+
echo "{\"status\": \"failure\"}" > $PLUGINS_DIR/$PLUGIN_NAME/$STATUS_FILE
3031
else
3132
echo "Success: Test plugin successfully updated from $BEFORE_PLUGIN_VERSION to $AFTER_PLUGIN_VERSION!"
32-
echo "::set-output name=status::pass"
33+
echo "{\"status\": \"success\"}" > $PLUGINS_DIR/$PLUGIN_NAME/$STATUS_FILE
3334
fi

0 commit comments

Comments
 (0)