Prevent release workflow on unmerged PRs #47
Workflow file for this run
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 | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [ closed ] | |
jobs: | |
changelog: | |
uses: ./.github/workflows/changelog.yml | |
release: | |
if: github.event.pull_request.merged == true && needs.changelog.outputs.release-type != 'no-release' | |
needs: [ changelog ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
- name: Configure Git author | |
run: | | |
git config --global user.name "Open Terms Archive Release Bot" | |
git config --global user.email "release-bot@opentermsarchive.org" | |
- name: Update changelog for release | |
id: release-changelog | |
uses: OpenTermsArchive/manage-changelog/release@v0.2.0 | |
- name: Build Collection | |
uses: artis3n/ansible_galaxy_collection@v2 | |
with: | |
api_key: '${{ secrets.GALAXY_API_KEY }}' | |
galaxy_version: '${{ steps.release-changelog.outputs.version }}' | |
build: true | |
publish: false | |
- name: Commit CHANGELOG.md and galaxy.yml changes and create tag | |
run: | | |
git add "CHANGELOG.md" "galaxy.yml" | |
git commit -m "Release ${{ steps.release-changelog.outputs.version }}" | |
git tag v${{ steps.release-changelog.outputs.version }} | |
- name: Run status checks for release commit on temporary branch # Use temporary branch to enable pushing commits to this branch protected by required status checks | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
branch: main | |
unprotect_reviews: true | |
- name: Push changes to repository | |
run: git push origin && git push --tags | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.release-changelog.outputs.version }} | |
body: ${{ steps.release-changelog.outputs.content }} | |
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
- name: Publish Collection on Ansible Galaxy | |
uses: artis3n/ansible_galaxy_collection@v2 | |
with: | |
api_key: '${{ secrets.GALAXY_API_KEY }}' | |
build: false | |
publish: true | |
clean_changelog: | |
if: github.event.pull_request.merged == true && needs.changelog.outputs.release-type == 'no-release' | |
needs: [ changelog ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
- name: Configure Git author | |
run: | | |
git config --global user.name "Open Terms Archive Release Bot" | |
git config --global user.email "release-bot@opentermsarchive.org" | |
- name: Update changelog for release | |
uses: OpenTermsArchive/manage-changelog/release@v0.2.0 | |
- name: Erase unreleased information from changelog | |
run: | | |
git commit -m "Clean changelog" CHANGELOG.md | |
git push origin |