Release Asset Check #3
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
name: Release Asset Check | |
on: | |
workflow_dispatch: | |
inputs: | |
tagName: | |
description: 'Tag Name to Process (leave empty for latest)' | |
required: false | |
default: '' | |
release: | |
types: [created, published] | |
jobs: | |
check-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install GitHub CLI | |
run: | | |
if ! command -v gh &> /dev/null | |
then | |
echo "GitHub CLI not found, installing..." | |
sudo apt update | |
sudo apt install -y gh | |
else | |
echo "GitHub CLI is already installed." | |
fi | |
gh --version | |
- name: Determine the Tag Name | |
id: get-tag-name | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.tagName }}" != "" ]]; then | |
echo "Using manually provided tag name: ${{ github.event.inputs.tagName }}" | |
echo "::set-output name=tag_name::${{ github.event.inputs.tagName }}" | |
else | |
echo "Determining the latest release tag..." | |
release_info=$(gh release view --json tagName -q .tagName) | |
echo "::set-output name=tag_name::$release_info" | |
fi | |
- name: Download the release asset | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Construct the asset file name | |
asset_name="${{ steps.get-tag-name.outputs.tag_name }}.zip" | |
echo "Looking for asset: $asset_name" | |
# Use GitHub CLI to download the asset | |
gh release download "${{ steps.get-tag-name.outputs.tag_name }}" \ | |
--pattern "$asset_name" \ | |
--dir . | |
- name: Extract the archive | |
run: | | |
asset_name="${{ steps.get-tag-name.outputs.tag_name }}.zip" | |
unzip "$asset_name" -d extracted | |
# - name: Check for the specific file | |
# run: | | |
# # Update this path to the expected location of your file within the extracted directory | |
# if [ -f "extracted/path/to/your/file" ]; then | |
# echo "File exists." | |
# else | |
# echo "File does not exist." | |
# exit 1 | |
# fi |