Skip to content

Commit

Permalink
Merge pull request #18 from nsquared-team/ci/input-release-tag
Browse files Browse the repository at this point in the history
CI/Release allow release of a specific input tag
  • Loading branch information
hsein-bitar committed Apr 17, 2023
2 parents 24a4fa6 + 3616ce3 commit 6cd464d
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ name: DA deploy to WordPress.org
on:
release:
types: [released]

workflow_dispatch:
inputs:
tag_name:
description: "Example '1.2.8' - if this tag does not exist on GitHub this release will fail without affecting WP.org repository"
required: false
default: ""
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Expand All @@ -32,19 +37,46 @@ jobs:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: "Set Tag Name for release"
id: set_tag_name
run: |
if [ -z "${{ github.event.inputs.tag_name }}" ]; then
echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "tag_name="${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
fi
# step to validate github output tag_name not empty
- name: "Validate Tag Name"
id: validate_tag_name
run: |
if [ -z "${{ steps.set_tag_name.outputs.tag_name }}" ]; then
echo "Error: tag_name is empty!"
exit 1
fi
- name: release-downloader
uses: robinraju/release-downloader@v1.7
id: release_download
with:
tag: ${{ github.event.release.tag_name }}
tag: ${{ steps.set_tag_name.outputs.tag_name }}
out-file-path: .
fileName: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-prerelease.zip

fileName: ${{ github.event.repository.name }}-${{ steps.set_tag_name.outputs.tag_name }}-prerelease.zip

# step to confirm the file was downloaded, otherwise exit
- name: "Confirm Release Downloaded"
id: confirm_release_downloaded
run: |
if [ ! -f ${{ github.event.repository.name }}-${{ steps.set_tag_name.outputs.tag_name }}-prerelease.zip ]; then
echo "Error: Release not downloaded! Confirm that a GitHub release with tag ${{ steps.set_tag_name.outputs.tag_name }} exists and has the prerelease ZIP attached"
exit 1
fi
- name: "Unzip the downloaded release ZIP"
id: release_unzip
run: |
unzip ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-prerelease.zip -d release
unzip ${{ github.event.repository.name }}-${{ steps.set_tag_name.outputs.tag_name }}-prerelease.zip -d release
- name: "Check downloaded files"
run: |
Expand Down Expand Up @@ -83,4 +115,4 @@ jobs:
env:
JSON: "{\"text\":\"\\n:red_circle: Draw Attention ${{ github.event.release.tag_name }}\\nFailed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\",\"blocks\":[{\"type\":\"divider\"},{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\"\\n:red_circle: Draw Attention ${{ github.event.release.tag_name }}\\n\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Failed to deploy.\\n\\nKindly check if the official version is affected and attempt a fix / another release. <https://wordpress.org/plugins/draw-attention|WordPress.org>\\n\"}}]}"
with:
payload: ${{ env.JSON }}
payload: ${{ env.JSON }}

0 comments on commit 6cd464d

Please sign in to comment.