Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Mar 20, 2024
1 parent da1191c commit a8f48a2
Show file tree
Hide file tree
Showing 31 changed files with 759 additions and 589 deletions.
7 changes: 6 additions & 1 deletion .github/actions/audit-changelog/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Audit changelog"
description: "Get metadata about a changelog, including the expected file path, and if it exists"
description: "Get metadata about a changelog"

inputs:
version:
Expand All @@ -17,6 +17,11 @@ outputs:
runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo version : ${{ inputs.version }}
- name: "Parse version: `${{ inputs.version }}`"
id: semver
uses: dbt-labs/actions/[email protected]
Expand Down
13 changes: 9 additions & 4 deletions .github/actions/audit-github-commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ outputs:
runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo sha : ${{ inputs.sha }}
- name: "Check if a release exists for `${{ inputs.sha }}`"
id: commit
env:
Expand All @@ -37,7 +42,7 @@ runs:
shell: bash
run: |
echo sha : ${{ inputs.sha }}
echo tag : ${{ steps.check_release_commit.outputs.tag_name }}
echo release-id : ${{ steps.check_release_commit.outputs.id }}
echo pre-release : ${{ steps.check_release_commit.outputs.prerelease }}
echo commitish : ${{ steps.check_release_commit.outputs.target_commitish }}
echo tag : ${{ steps.commit.outputs.tag_name }}
echo release-id : ${{ steps.commit.outputs.id }}
echo pre-release : ${{ steps.commit.outputs.prerelease }}
echo commitish : ${{ steps.commit.outputs.target_commitish }}
14 changes: 10 additions & 4 deletions .github/actions/audit-github-tag/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ outputs:
runs:
using: composite
steps:
- name: "Check if `${{ inputs.tag }}` exists in `${{ inputs.repo-url }}`"
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo tag : ${{ inputs.tag }}
echo repo-url : ${{ inputs.repo-url }}
- name: "Set: exists"
id: tag
shell: bash
run: |
Expand All @@ -38,15 +44,15 @@ runs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Get the commit associated with `${{ inputs.tag }}`"
- name: "Set: sha"
id: commit
if: ${{ fromJSON(steps.tag.outputs.exists) == true }}
shell: bash
run: |
sha=$(jq -r '.targetCommitish' <<< "$output")
sha=$(jq -r '.targetCommitish' <<< "${{ steps.tag.outputs.results }}")
echo "sha=$sha" >> $GITHUB_OUTPUT
- name: "Check if `${{ inputs.tag }}` is a draft release"
- name: "Set: is-draft"
id: draft
if: ${{ fromJSON(steps.tag.outputs.exists) == true }}
shell: bash
Expand Down
25 changes: 17 additions & 8 deletions .github/actions/audit-github-team/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "Audit GitHub team"
description: "Get metadata about a GitHub team, such as a list of team members"
description: "Get metadata about a GitHub team"

inputs:
organization:
description: "The GitHub organization that owns the team"
required: true
default: "dbt-labs"
team:
description: "The name of the team"
required: true
Expand All @@ -17,30 +17,39 @@ outputs:
runs:
using: composite
steps:
- name: "Set: output file name"
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo organization : ${{ inputs.organization }}
echo team : ${{ inputs.team }}
- name: "Create output file name"
id: output-file
shell: bash
run: echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT

- name: "Get team membership for `${{ inputs.organization }}/${{ inputs.team }}`"
- name: "Get team membership"
shell: bash
run: |
url = orgs/${{ inputs.organization }}/teams/${{ inputs.team }}/members
header = Accept: application/vnd.github+json
gh api -H "$header" $url > ${{ steps.output-file.outputs.name }}
- name: "Parse team membership"
id: members
shell:
shell: bash
run: |
team_list=$(jq -r '.[].login' ${{ steps.output-file.outputs.name }})
team_list_single=$(echo $team_list | tr '\n' ' ')
echo "membership=$team_list_single" >> $GITHUB_OUTPUT
- name: "Delete the output file"
shell: bash
run: rm ${{ steps.output-file.outputs.name }}

- name: "[DEBUG] Parse team membership"
shell: bash
run: |
echo organization : ${{ inputs.organization }}
echo team : ${{ inputs.team }}
echo members : ${{ steps.members.outputs.membership }}
- name: "Delete the output file"
run: rm ${{ steps.output-file.outputs.name }}
6 changes: 6 additions & 0 deletions .github/actions/create-temp-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ outputs:
runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo branch-stub : ${{ inputs.branch-stub }}
- name: "Create a unique branch name"
id: branch
shell: bash
run: |
name="${{ inputs.branch-stub }}"
name+="$(date +'%Y-%m-%d')/$GITHUB_RUN_ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@ inputs:
description: "The email for the commit"
default: "[email protected]"

outputs:
path:
description: "The file path to the change log, relative to the repo root"
value: ${{ steps.path.outputs.path }}
exists:
description: "Does the changelog exist?"
value: ${{ steps.exists.outputs.exists }}

runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo message : ${{ inputs.message }}
echo user : ${{ inputs.user }}
echo email : ${{ inputs.email }}
- name: "Commit and push changes"
shell: bash
run: |
git config user.name "${{ inputs.user }}"
git config user.email "${{ inputs.email }}"
git pull
git add .
git commit -m "${{ inputs.message }}"
git commit -m "[automated] ${{ inputs.message }}"
git push
- name: "[INFO] Committed and pushed changes"
shell: bash
run: |
title="Committed and pushed changes"
message="Committed and pushed changes back up to remote"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
59 changes: 59 additions & 0 deletions .github/actions/github-merge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Merge GitHub branch"
description: "Merge one branch into another on GitHub"

inputs:
source-branch:
description: "The source branch to be merged"
required: true
target-branch:
description: "The target branch to receive the merge"
required: true
message:
description: "Commit message for the merge"
required: true
delete-source-branch:
description: "Will delete the source branch after merging"
default: "true"

outputs:
sha:
description: "The commit SHA for the merge"
value: ${{ steps.merge-sha.outputs.sha }}

runs:
using: composite
steps:
# TODO: are we comfortable passing our bot token to this third party action?
- name: "Merge `${{ inputs.source-branch }}` into `${{ inputs.target-branch }}`"
uses: everlytic/[email protected]
with:
source_ref: ${{ inputs.source-branch }}
target_branch: ${{ inputs.target-branch }}
commit_message_template: "[automated] ${{ inputs.message }}"
github_token: ${{ secrets.FISHTOWN_BOT_PAT }}

- name: "Checkout `${{ inputs.branch }}`"
uses: actions/checkout@v3
with:
ref: ${{ inputs.target-branch }}

# TODO: see if everlytic/branch-merge has outputs that have this information
- name: "Get commit SHA for the merge"
id: merge-sha
shell: bash
run: |
git pull
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
# TODO: see if everlytic/branch-merge has options to do this
- name: "Delete `${{ inputs.source-branch }}`"
if: ${{ fromJSON(inputs.delete-source-branch) }}
shell: bash
run: git push origin -d ${{ inputs.source-branch }}

- name: "[INFO] Merged changes"
shell: bash
run: |
title="Merged changes"
message="${{ inputs.source-branch }} was merged into ${{ inputs.target-branch }} with sha ${{ steps.merge-sha.outputs.sha }}"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
22 changes: 22 additions & 0 deletions .github/actions/log-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Raise a notification"
description: "Raises a notification to the workflow summary in a standardized pattern"

inputs:
title:
description: "The notification title"
required: true
message:
description: "The detailed message"
required: true
prefix:
description: "The parent process raising the notification"
default: "INFO"

runs:
using: composite
steps:
- shell: bash
run: 'echo "::notice title=$TITLE::$MESSAGE"'
env:
TITLE: "[${{ inputs.prefix }}]: ${{ inputs.title }}"
MESSAGE: ${{ inputs.message }}
61 changes: 11 additions & 50 deletions .github/actions/publish-github-draft/action.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,32 @@
name: "Publish to GitHub as draft release"
description: "Publish artifacts from an archive to GitHub as a draft release"
name: "Publish GitHub draft release as full release"
description: "Publish an existing draft release as a non-draft release"

inputs:
archive-name:
description: "Name of the archive containing the artifacts, leave blank if local"
default: ""
tag:
description: "The release tag to publish under"
description: "The tag to publish (i.e. v1.0.0b1)"
required: true
repo-url:
description: "The URL to the repo (https://github.com/dbt-labs/dbt-adapters"
required: true
sha:
description: "Commit SHA being released"
required: true
changelog-path:
description: "Path to the release notes"
required: true

runs:
using: composite
steps:
- name: "Download artifacts from `${{ inputs.archive-name }}`"
if: ${{ !(inputs.archive-name == "" }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.archive-name }}
path: dist/

- name: "[INFO] Downloaded artifacts"
if: ${{ !(inputs.archive-name == "" }}
shell: bash
run: |
title="Downloaded artifacts"
message="Downloaded artifacts from ${{ inputs.archive-name }}"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
- name: "[DEBUG] Found artifacts"
shell: bash
working-directory: ${{ inputs.working-dir }}
run: echo $(ls ./dist)

- name: "Set: pre-release"
id: pre-release
- name: "[DEBUG] Inputs"
shell: bash
run: |
if ${{ contains(inputs.tag, 'rc') || contains(inputs.tag, 'b') || contains(inputs.tag, 'a') }}
then
echo "pre-release=--prerelease" >> $GITHUB_OUTPUT
fi
echo tag : ${{ inputs.tag }}
echo repo-url : ${{ inputs.repo-url }}
- name: "Publish artifacts to GitHub as draft release"
- name: "Publish `${{ inputs.tag }}` as full release"
shell: bash
run: |
gh release create $TAG ./dist/* --title "$TITLE" --notes-file $RELEASE_NOTES --target $COMMIT $PRERELEASE --draft --repo ${{ inputs.repo-url }}
run: gh release edit ${{ inputs.tag }} --repo ${{ inputs.repo-url }} --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
TITLE: ${{ github.event.repository.name }} ${{ inputs.tag }}
RELEASE_NOTES: ${{ inputs.changelog-path }}
COMMIT: ${{ inputs.sha }}
PRERELEASE: ${{ steps.pre-release.outputs.pre-release }}
DRAFT: ${{ inputs.draft-flag }}

- name: "[INFO] Published artifacts to GitHub as draft release"
- name: "[INFO] Published draft as full release"
shell: bash
run: |
title="Published artifacts to GitHub as draft release"
message="artifacts: $(ls ./dist) tag: ${{ inputs.tag }} pre-release: ${{ steps.prerelease.outputs.prerelease }}"
title="Released draft as non-draft release on GitHub"
message="tag: ${{ inputs.tag }} repo: ${{ inputs.repo-url }}"
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message"
26 changes: 0 additions & 26 deletions .github/actions/publish-github-full/action.yml

This file was deleted.

Loading

0 comments on commit a8f48a2

Please sign in to comment.