Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-861: Add Git tags for Azure deployments and swaps #375

Merged
merged 56 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5569ad5
Initial testing done
AydinE Jul 19, 2024
0af19fd
YAML linting fixes
AydinE Jul 19, 2024
b33546f
Passthrough options in release action
AydinE Jul 19, 2024
cfd8cec
Update tag-deployment.yml
AydinE Jul 19, 2024
c151bc1
expected ref
AydinE Jul 19, 2024
2dddc76
refs and linting fixes
AydinE Jul 19, 2024
8f081ce
Add directly to existing workflows
AydinE Jul 22, 2024
b37b0c4
YAML linting
AydinE Jul 22, 2024
1819a9e
Formatting
AydinE Jul 22, 2024
b3ef953
Formatting
Piedone Jul 23, 2024
31efd2c
Review changes
AydinE Jul 24, 2024
c55b337
Conflicts
AydinE Jul 24, 2024
bfe34d4
Merge branch 'dev' into issue/OSOE-861
AydinE Jul 24, 2024
50a5f9a
YAML linting
AydinE Jul 24, 2024
6773d17
rename to app-code-repo
AydinE Jul 24, 2024
abc8de4
More long git CLI switches
Piedone Jul 24, 2024
144cff3
Formatting
Piedone Jul 24, 2024
771611d
Add optional ref
AydinE Aug 5, 2024
ff13fc3
Merge branch 'issue/OSOE-861' of https://github.com/Lombiq/GitHub-Act…
AydinE Aug 5, 2024
eb8b629
Actions versions
AydinE Aug 5, 2024
ab5c0f3
Fix review points
AydinE Aug 7, 2024
6a2ff61
Update deploy-to-azure-app-service.yml
AydinE Aug 7, 2024
530fb9c
Change defaults to staging
AydinE Aug 7, 2024
b671f73
timestamp output
AydinE Aug 7, 2024
0cdb7a4
Timestamp fixes
AydinE Aug 7, 2024
c4ffd16
Change when timestamp is created in workflow
AydinE Aug 8, 2024
6dc1e80
Remove redundant quotes
AydinE Aug 8, 2024
24d0b3a
Move timestamp creation moment
AydinE Aug 8, 2024
db8485f
Release Annotation Timestamp
AydinE Aug 9, 2024
ba715f6
Pass timestamp to action
AydinE Aug 9, 2024
be6a8a2
actual timestamp and timestamp tag
AydinE Aug 9, 2024
c899181
Update action.yml
AydinE Aug 9, 2024
3940453
Renames, docs updates and fixes
AydinE Aug 12, 2024
d4a43e7
Update swap-azure-web-app-slots.yml
AydinE Aug 12, 2024
ba7c713
Update action.yml
AydinE Aug 12, 2024
2cf5ba4
Optional sha for ai annotation
AydinE Aug 14, 2024
681b507
Passthrough submodules input for checkout
AydinE Aug 14, 2024
75c459a
Checkout refs
AydinE Aug 14, 2024
46ec11c
refs
AydinE Aug 14, 2024
5850112
Tag proper commit
AydinE Aug 16, 2024
1850ce6
Merge branch 'dev' into issue/OSOE-861
AydinE Aug 16, 2024
3592c6e
Update swap-azure-web-app-slots.yml
AydinE Aug 16, 2024
acead90
Docs
Piedone Aug 16, 2024
3a63e45
Changes based on review
AydinE Aug 19, 2024
d60dd83
Merge branch 'issue/OSOE-861' of https://github.com/Lombiq/GitHub-Act…
AydinE Aug 19, 2024
8da0f5c
PS syntax fix
Piedone Aug 20, 2024
0f75b3c
Fixing copy-paste error and output name
Piedone Aug 20, 2024
fb759d4
Update action.yml
AydinE Aug 21, 2024
e5c2e5b
Merge branch 'issue/OSOE-861' of https://github.com/Lombiq/GitHub-Act…
AydinE Aug 21, 2024
f29852d
Update swap-azure-web-app-slots.yml
AydinE Aug 29, 2024
a6ad302
Update swap-azure-web-app-slots.yml
AydinE Aug 29, 2024
496a454
Update SwapAzureWebAppSlots.md
AydinE Aug 29, 2024
f9437f5
Adding notice message to the swap workflow about which commit was swa…
Piedone Aug 29, 2024
fbb0ba9
Reverting issue branch references for GHA
Piedone Aug 29, 2024
3955986
Dummy change to kick off build
Piedone Aug 29, 2024
d1ce2bd
Revert "Dummy change to kick off build"
Piedone Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/publish-nuget/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ runs:
retention-days: ${{ inputs.nuget-artifact-retention-days }}

- name: Create Release
uses: Lombiq/GitHub-Actions/.github/actions/release-action@dev
uses: Lombiq/GitHub-Actions/.github/actions/release-action@issue/OSOE-861
# This is to prevent creating releases when pushing tags for issue-specific pre-releases like
# v4.3.1-alpha.osoe-86.
if: "!contains(steps.setup.outputs.publish-version, '-')"
Expand Down
10 changes: 10 additions & 0 deletions .github/actions/release-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ inputs:
description: An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).
required: false
default: ''
repo:
description: Optionally specify the repo where the release should be generated. Defaults to current repo.
required: false
default: ''
token:
description: The GitHub token.
required: false
default: ${{ github.token }}

outputs:
id:
Expand All @@ -49,3 +57,5 @@ runs:
artifacts: ${{ inputs.artifacts }}
generateReleaseNotes: ${{ inputs.generateReleaseNotes }}
tag: ${{ inputs.tag }}
repo: ${{ inputs.repo }}
token: ${{ inputs.token }}
Piedone marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Publish to NuGet
uses: Lombiq/GitHub-Actions/.github/actions/publish-nuget@dev
uses: Lombiq/GitHub-Actions/.github/actions/publish-nuget@issue/OSOE-861
with:
source: ${{ inputs.source }}
verbosity: ${{ inputs.verbosity }}
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/tag-deployment.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Tag Deployment
on:
workflow_call:
secrets:
TAG_VERSION_TOKEN:
default: ${{ github.token }}
required: false
description: >
An authentication token, like a personal access token (PAT) that gives access to the other repository.
This is necessary because the repository that triggered the workflow and the repository that the workflow is
running on can be different. (For example: in cases of a swap).
inputs:
repo_url:
default: ${{ github.repository }}
required: false
type: string
description: >
The URL of the repository to tag. This is necessary because the repository that triggered the workflow and the
repository that the workflow is running on can be different. (For example: in cases of a swap).
is_swap:
required: false
default: false
type: boolean
description: >
Whether this is a swap operation. This will add a tag with {prefix}/latest to the commit that is currently
tagged with the {swap_prefix}/latest tag. This is useful for deployment scenarios where you want to keep
track of the latest deployment and the history of deployments.
prefix:
required: true
type: string
description: >
Prefix for the tags (e.g., staging or production). This will be used to create tags like
`staging/latest` and `staging/2021-01-01-12.34UTC`.
swap_prefix:
required: false
type: string
description: >
Prefix for looking up the swap tags (e.g., staging). This will be used to look up tags like `staging/latest`
to determine the latest commit that was deployed to add a new tag to alongside, like 'production/latest'.

jobs:
run:
name: Set GitHub Action/Workflow to Version Tag
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- name: Checkout Repository
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
repository: ${{ inputs.repo_url }}
token: ${{ secrets.TAG_VERSION_TOKEN }}

- name: Setup Git Config
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"

- name: Fetch tags
id: fetch-tags
run: |
git fetch --tags

- name: Determine timestamp
id: determine-timestamp
run: |
# Get the current timestamp in the format of yyyy-MM-dd-HH.mmUTC - can't use : in tags
"timestamp=$(Get-Date -Format 'yyyy-MM-dd-HH.mmUTC')" >> $Env:GITHUB_OUTPUT

- name: Delete Old prefix/latest tag
run: |
$latestTag = (git tag -l "${{ inputs.prefix }}/latest")
if ($latestTag)
{
git tag -d "${{ inputs.prefix }}/latest"
git push origin ":refs/tags/${{ inputs.prefix }}/latest"
}

- name: Move Latest Tag (Swap) and Add Timestamp Tag
if: inputs.is_swap == true
run: |
if([string]::IsNullOrEmpty("${{ inputs.swap_prefix }}"))
Piedone marked this conversation as resolved.
Show resolved Hide resolved
{
throw "Swap prefix not set, exiting"
}

$tagExists = (git tag -l "${{ inputs.swap_prefix }}/latest")
if ([string]::IsNullOrEmpty($tagExists)){
throw "No latest tag found for swap prefix"
}

$latest = (git rev-list -n 1 "${{ inputs.swap_prefix }}/latest")
if ($latest)
{
git tag -a "${{ inputs.prefix }}/latest" $latest -m "Latest tag for ${{ inputs.prefix }}"
git push origin tag "${{ inputs.prefix }}/latest"
$gitMessage = "Swap tagged at ${{steps.determine-timestamp.outputs.timestamp}}"
git tag -a "${{ inputs.prefix }}/${{steps.determine-timestamp.outputs.timestamp}}" $latest -m $gitMessage
git push origin tag "${{ inputs.prefix }}/${{steps.determine-timestamp.outputs.timestamp}}"
} else {
throw "No latest tag found for swap prefix"
}

- name: Create Release
uses: Lombiq/GitHub-Actions/.github/actions/release-action@issue/OSOE-861
if: inputs.is_swap == true
with:
repo: ${{ inputs.repo_url }}
token: ${{ secrets.TAG_VERSION_TOKEN }}
tag: ${{ inputs.prefix }}/latest
allowUpdates: true
generateReleaseNotes: true
artifacts: artifacts/*.nupkg, artifacts/*.snupkg

- name: Tag Latest and add Timestamp Tag
if: inputs.is_swap == false
run: |
git tag "${{ inputs.prefix }}/latest"
git push origin tag "${{ inputs.prefix }}/latest"
git tag "${{ inputs.prefix }}/${{steps.determine-timestamp.outputs.timestamp}}"
git push origin tag "${{ inputs.prefix }}/${{steps.determine-timestamp.outputs.timestamp}}"
2 changes: 1 addition & 1 deletion .github/workflows/tag-version-this-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
run:
name: Tag Version Automation
if: github.event.pusher.name != 'LombiqBot'
uses: Lombiq/GitHub-Actions/.github/workflows/tag-version.yml@dev
uses: Lombiq/GitHub-Actions/.github/workflows/tag-version.yml@issue/OSOE-861
with:
additional-pattern-include-list: '@("https://raw.githubusercontent.com/Lombiq/GitHub-Actions/(?<ref>[\w\./-]*)/.github")'
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
run: git push --tags --force

- name: Create Release
uses: Lombiq/GitHub-Actions/.github/actions/release-action@dev
uses: Lombiq/GitHub-Actions/.github/actions/release-action@issue/OSOE-861
# This is to prevent creating releases when pushing tags for issue-specific pre-releases like
# v4.3.1-alpha.osoe-86.
if: "!contains(steps.determine-tag.outputs.tagname, '-')"
Expand Down
Loading