Skip to content

Commit

Permalink
Renamed deploy.yml -> cd.yml: Now triggered on push to main, autotagg…
Browse files Browse the repository at this point in the history
…ing of release, workflow undeploys prereleases
  • Loading branch information
CodeGat committed Feb 2, 2024
1 parent 04b3b12 commit 0716199
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 13 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CD
on:
push:
branches:
- main

jobs:
generate-tag:
name: Generate Tag Name
# Get the tag name from the branch that was merged into main, which
# is of the form `pre-<version>`.
# We assume that this will always be the most recent merged PR, as
# this workflow kicks off immediately after the merge completes.
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
name: ${{ steps.tag.outputs.name }}
steps:
- uses: actions/checkout@v4

- name: Generate Tag
id: tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
# We use the `gh` utility as it offers much easier traversal of GitHub-
# related things (prs, issues, etc...).
# The `cut` command splits the `pre-<version>` branch into just `<version>`,
# which will be the new tag.
run: |
merged_branch=$(gh pr list \
--state merged \
--limit 1 \
--json 'headRefName' \
--jq '.[].headRefName')
echo "name=$(cut --delimiter '-' --fields 2 <<< '$merged_branch')" >> $GITHUB_OUTPUT
undeploy-prereleases:
name: Undeploy Prereleases
needs:
- generate-tag
uses: access-nri/build-cd/.github/workflows/undeploy-1-setup.yml@main
with:
version-pattern: ${{ needs.generate-tag.outputs.name }}-pre*
secrets: inherit

deploy-release:
name: Deploy Release
needs:
- generate-tag
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@main
with:
version: ${{ needs.generate-tag.outputs.name }}
secrets: inherit
permissions:
contents: write

push-tag:
name: Tag Deployment
needs:
- generate-tag
- deploy-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Push Tag
run: |
git tag ${{ needs.generate-tag.outputs.name }}
git push --tags
13 changes: 0 additions & 13 deletions .github/workflows/deploy.yml

This file was deleted.

0 comments on commit 0716199

Please sign in to comment.