Publish NAV appliance release #98
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: Publish NAV appliance release | |
on: | |
workflow_run: | |
workflows: ["Build NAV appliance"] | |
types: | |
- completed | |
jobs: | |
publish: | |
name: "Publish appliance as release" | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.conclusion == 'success' | |
&& github.event.workflow_run.head_repository.full_name == github.repository | |
permissions: | |
contents: write | |
steps: | |
- name: Download artifacts | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
artifacts_url=${{ github.event.workflow_run.artifacts_url }} | |
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact | |
do | |
IFS=$'\t' read name url <<< "$artifact" | |
gh api $url > "$name.zip" | |
done | |
- name: Get build details | |
id: details | |
run: | | |
if [ -f version.zip ]; then | |
unzip version.zip | |
fi | |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
echo "nav_version=$(cat version.txt)" >> $GITHUB_OUTPUT | |
echo "expected_tag=v$(cat version.txt)" >> $GITHUB_OUTPUT | |
- name: Publish artifacts as release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "navappliance.zip,version.txt" | |
name: ${{ steps.details.outputs.nav_version }} | |
body: "Automated build on ${{ steps.details.outputs.date }}, using version ${{ steps.details.outputs.nav_version }} of NAV Debian package" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true | |
tag: ${{ steps.details.outputs.expected_tag }} |