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 10 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
34 changes: 34 additions & 0 deletions .github/workflows/deploy-to-azure-app-service.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ on:
description: >
Compiles application assemblies as ReadyToRun (R2R) format. R2R is a form of ahead-of-time (AOT) compilation.
If ready to run is set to `true` the `runtime` input is needed.
tag-prefix:
type: string
required: false
default: ${{ inputs.slot-name }}
description: >
The prefix to use for the tag. If not set, the slot name will be used as the prefix. The tag will be in the
format of "<prefix>/latest" and "<prefix>/<timestamp>".
Piedone marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy:
Expand Down Expand Up @@ -247,6 +254,33 @@ jobs:
-WebAppName ${{ inputs.app-name }} `
-SlotName ${{ inputs.slot-name }}

- name: Fetch tags
Piedone marked this conversation as resolved.
Show resolved Hide resolved
id: fetch-tags
run: |
git fetch --tags

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

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

- name: Tag Latest and add Timestamp Tag
run: |
git tag '${{ inputs.tag-prefix }}/latest'
git push origin tag '${{ inputs.tag-prefix }}/latest'
git tag '${{ inputs.tag-prefix }}/${{steps.determine-timestamp.outputs.timestamp}}'
git push origin tag '${{ inputs.tag-prefix }}/${{steps.determine-timestamp.outputs.timestamp}}'

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/cancel-workflow@dev
Expand Down
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
101 changes: 101 additions & 0 deletions .github/workflows/swap-azure-web-app-slots.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ on:
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.
TAG_DEPLOYMENT_TOKEN:
Piedone marked this conversation as resolved.
Show resolved Hide resolved
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 are different in this case.

inputs:
cancel-workflow-on-failure:
Expand Down Expand Up @@ -69,6 +76,26 @@ on:
description: >
ID of the Application Insights resource that the release annotation for the swap should be added to.
This can e.g. be looked up on the Azure Portal under the given AI resource's Overview page -> JSON View.
swap-code-repo:
Piedone marked this conversation as resolved.
Show resolved Hide resolved
type: string
default: ''
required: false
description: >
The repository that hosts the code that will be swapped. This is necessary for adding tags.
Piedone marked this conversation as resolved.
Show resolved Hide resolved
tag-prefix:
type: string
default: ${{ inputs.destination-slot-name }}
required: false
description: >
Piedone marked this conversation as resolved.
Show resolved Hide resolved
The prefix for the tags that will be added to the swap-code-repo. If not set, the slot name will be used as
the prefix. The tag will be in the format of "<prefix>/latest" and "<prefix>/<timestamp>".
swap-prefix:
type: string
default: ${{ inputs.source-slot-name }}
required: false
description: >
The prefix of the deployment tag that we will be looking for in the swap-code-repo. If not set, the source
slot name will be used as the prefix.

jobs:
swap-azure-web-app-slots:
Expand Down Expand Up @@ -118,6 +145,80 @@ jobs:
-WebAppName ${{ inputs.app-name }} `
-SlotName ${{ inputs.destination-slot-name }}

- name: Checkout Repository
Piedone marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.swap-code-repo != ''
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
repository: ${{ inputs.swap-code-repo }}
token: ${{ secrets.TAG_DEPLOYMENT_TOKEN }}

- name: Setup Git Config
if: inputs.swap-code-repo != ''
Piedone marked this conversation as resolved.
Show resolved Hide resolved
run: |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]'

- name: Fetch tags
if: inputs.swap-code-repo != ''
run: |
git fetch --tags

- name: Determine timestamp
if: inputs.swap-code-repo != ''
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
Piedone marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.swap-code-repo != ''
run: |
$latestTag = (git tag -l '${{ inputs.tag-prefix }}/latest')
if ($latestTag)
{
git tag -d '${{ inputs.tag-prefix }}/latest'
git push origin ':refs/tags/${{ inputs.tag-prefix }}/latest'
}

- name: Move Latest Tag (Swap) and Add Timestamp Tag
if: inputs.swap-code-repo != ''
run: |
if([string]::IsNullOrEmpty('${{ inputs.tag-prefix }}'))
{
throw 'Tag prefix not set, exiting'
Piedone marked this conversation as resolved.
Show resolved Hide resolved
}

$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.tag-prefix }}/latest' $latest -m 'Latest tag for ${{ inputs.tag-prefix }}'
git push origin tag '${{ inputs.tag-prefix }}/latest'
$gitMessage = 'Swap tagged at ${{steps.determine-timestamp.outputs.timestamp}}'
git tag -a '${{ inputs.tag-prefix }}/${{steps.determine-timestamp.outputs.timestamp}}' $latest -m $gitMessage
git push origin tag '${{ inputs.tag-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
Piedone marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.swap-code-repo != ''
with:
repo: ${{ inputs.swap-code-repo }}
token: ${{ secrets.TAG_DEPLOYMENT_TOKEN }}
tag: ${{ inputs.tag-prefix }}/latest
Piedone marked this conversation as resolved.
Show resolved Hide resolved
allowUpdates: true
generateReleaseNotes: true
artifacts: artifacts/*.nupkg, artifacts/*.snupkg
Piedone marked this conversation as resolved.
Show resolved Hide resolved

- name: Cancel Workflow on Failure
if: failure() && inputs.cancel-workflow-on-failure == 'true'
uses: Lombiq/GitHub-Actions/.github/actions/cancel-workflow@dev
Expand Down
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