-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run release action only on the main branch, Fixes #9
- Loading branch information
Showing
1 changed file
with
25 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,27 +7,46 @@ on: # yamllint disable-line rule:truthy | |
workflow_dispatch: {} | ||
|
||
jobs: | ||
check-current-branch: | ||
runs-on: 'ubuntu-latest' | ||
outputs: | ||
branch: '${{ steps.check_step.outputs.branch }}' | ||
steps: | ||
- name: 'Checkout' | ||
uses: 'actions/checkout@v4' | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 'Determine current branch' | ||
id: 'check_step' | ||
# 1. Get the list of branches ref where this tag exists | ||
# 2. Remove 'origin/' from that result | ||
# 3. Put that string in output | ||
run: | | ||
raw=$(git branch -r --contains ${{ github.ref }}) | ||
branch="$(echo ${raw//origin\//} | tr -d '\n')" | ||
echo "{name}=branch" >> $GITHUB_OUTPUT | ||
echo "Branches where this tag exists : $branch." | ||
build: | ||
name: 'Publish to Ansible Galaxy' | ||
runs-on: 'ubuntu-latest' | ||
needs: 'check-current-branch' | ||
steps: | ||
- name: 'checkout' | ||
uses: 'actions/checkout@v4' | ||
if: >- | ||
github.ref == 'refs/heads/main' | ||
if: "contains(${{ needs.check.outputs.branch }}, 'main')" | ||
|
||
- name: 'galaxy' | ||
uses: 'robertdebock/[email protected]' | ||
if: >- | ||
github.ref == 'refs/heads/main' | ||
if: "contains(${{ needs.check.outputs.branch }}, 'main')" | ||
with: | ||
galaxy_api_key: '${{ secrets.galaxy_api_key }}' | ||
git_branch: 'main' | ||
|
||
- name: 'Create a new release on GitHub' | ||
uses: 'softprops/action-gh-release@v2' | ||
if: >- | ||
github.ref == 'refs/heads/main' | ||
if: "contains(${{ needs.check.outputs.branch }}, 'main')" | ||
with: | ||
draft: false | ||
prerelease: false | ||
|