Skip to content

Added Support to with local environment variable (#1256) #46

Added Support to with local environment variable (#1256)

Added Support to with local environment variable (#1256) #46

name: create-release-and-trigger-publish
on:
push:
branches-ignore:
- '**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
tag_exists: ${{ steps.check.outputs.exists }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check if tag exists
id: check
run: |
if git ls-remote --tags origin | grep -q "refs/tags/${GITHUB_REF_NAME}$"; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
create-release:
needs: [check-tag]
if: needs.check_tag.outputs.tag_exists == 'false'
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.set-output.outputs.created }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Set output
id: set-output
run: echo "created=true" >> $GITHUB_ENV
trigger-publish:
needs: [check-tag]
runs-on: ubuntu-latest
if: always()
steps:
- name: Determine whether to publish
run: |
if [ "${{ needs.check-tag.outputs.tag_exists }}" == "true" ]; then
echo "Tag already exists. Proceeding with publish."
elif [ "${{ github.event_name }}" == "push" ]; then
echo "Release job probably ran. Proceeding with publish."
else
echo "Conditions not met. Skipping publish."
exit 1
fi
- name: Trigger NPM publish
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: vtex/toolbelt
event-type: publish-stable-npm
- name: Trigger AWS publish
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: vtex/toolbelt
event-type: publish-stable-aws