Skip to content

Commit 4a667fc

Browse files
authored
[CICD-190] Replace deprecated set output command (#71)
* Replace deprecated set-output usage These are just the drop-in replacements. There is one more instance that will take some refactoring. * Validate deploy with HTTP request 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. * Fix slack connection by using channel ID
1 parent da5a6f2 commit 4a667fc

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

.github/actions/get-release-notes/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ runs:
2020
notes="${notes//'%'/'%25'}"
2121
notes="${notes//$'\n'/'%0A'}"
2222
notes="${notes//$'\r'/'%0D'}"
23-
echo "::set-output name=RELEASE_NOTES::$notes"
23+
echo "RELEASE_NOTES=$notes" >> $GITHUB_OUTPUT
2424
shell: bash

.github/actions/publish/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ for tag in "${tagsToUpdate[@]}"; do
5959
git push origin "$tag" --force
6060
done
6161

62-
echo "::set-output name=PUBLISHED::$PUBLISHED"
62+
echo "PUBLISHED=$PUBLISHED" >> $GITHUB_OUTPUT

.github/workflows/e2e-deploy.yml

Lines changed: 13 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 }}
1816
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: GitHub Action Deploy to WP Engine
23-
id: deploy
2421
uses: ./
2522
with:
2623
# Deploy vars
@@ -33,19 +30,26 @@ 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://ghae2e.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
43+
if: ${{ !cancelled() }}
3844
needs: run_action
3945
steps:
40-
- name: Validate deploy results
41-
run: |
42-
[ ${{needs.run_action.outputs.status}} = "pass" ] || exit 1
4346
- name: Notify slack on failure
44-
if: failure() && github.ref == 'refs/heads/main'
47+
if: needs.run_action.result == 'failure' && github.ref == 'refs/heads/main'
4548
env:
4649
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
4750
uses: voxmedia/github-action-slack-notify-build@v1
4851
with:
49-
channel: status-github-action
52+
# Channel: status-github-action
53+
channel_id: C03QDL9U0TW
5054
status: FAILED
5155
color: danger

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Get current version
3939
id: version
40-
run: echo "::set-output name=CURRENT_VERSION::$(node -p "require('./package.json').version")"
40+
run: echo "CURRENT_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
4141

4242
release:
4343
name: Release

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
@@ -25,8 +26,8 @@ echo "Old test plugin version: $BEFORE_PLUGIN_VERSION"
2526
# Check that the expected update was made
2627
if [ -z "$BEFORE_PLUGIN_VERSION" ] || [ -z "$AFTER_PLUGIN_VERSION" ] || [ "$BEFORE_PLUGIN_VERSION" = "$AFTER_PLUGIN_VERSION" ]; then
2728
echo "Failure: Test plugin was not updated!"
28-
echo "::set-output name=status::fail"
29+
echo "{\"status\": \"failure\"}" > $PLUGINS_DIR/$PLUGIN_NAME/$STATUS_FILE
2930
else
3031
echo "Success: Test plugin successfully updated from $BEFORE_PLUGIN_VERSION to $AFTER_PLUGIN_VERSION!"
31-
echo "::set-output name=status::pass"
32+
echo "{\"status\": \"success\"}" > $PLUGINS_DIR/$PLUGIN_NAME/$STATUS_FILE
3233
fi

0 commit comments

Comments
 (0)