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 43 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
param(
[parameter(Mandatory = $true)][string]$ApplicationInsightsResourceId,
[parameter(Mandatory = $true)][string]$ReleaseName,
[parameter(Mandatory = $false)][string]$Timestamp = '',
[parameter(Mandatory = $false)]$ReleaseProperties = @()
)

Expand All @@ -9,7 +10,7 @@ Write-Output "Adding release annotation with the release name `"$ReleaseName`"."
$annotation = @{
Id = [Guid]::NewGuid()
AnnotationName = $ReleaseName
EventTime = (Get-Date).ToUniversalTime().GetDateTimeFormats('s')[0]
EventTime = if ($Timestamp) { $Timestamp } else { (Get-Date).ToUniversalTime().GetDateTimeFormats('s')[0] }
# AI only displays annotations from the "Deployment" category so this must be this string.
Category = 'Deployment'
Properties = ConvertTo-Json $ReleaseProperties -Compress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ inputs:
required: false
description: >
The name to give the created release annotation. This will be visible on the Azure Portal when viewing it.
timestamp:
required: false
description: >
The timestamp to use for the release annotation. If not set then the current time will be used. This can be useful
when using a single timestamp for multiple actions in a workflow.
commit-sha:
required: false
default: ${{ github.sha }}
description: >
The commit SHA to include in the release annotation. If not set then the current commit SHA will be used. This is
useful in case of a swap deployment where the code repository is different than the repository the action is
running in.

runs:
using: composite
Expand All @@ -28,13 +40,15 @@ runs:
# Might contain user input so should go via an env var for security.
RELEASE_NAME: ${{ inputs.release-name }}
AI_RESOURCE_ID: ${{ inputs.application-insights-resource-id }}
TIMESTAMP: ${{ inputs.timestamp }}
run: |
$params = @{
ApplicationInsightsResourceId = $Env:AI_RESOURCE_ID
ReleaseName = $Env:RELEASE_NAME ? $Env:RELEASE_NAME : 'Run #${{ github.run_number }} (GitHub Actions)'
Timestamp = $Env:TIMESTAMP
ReleaseProperties = @{
'Commit branch' = '${{ github.head_ref }}'
'Commit SHA' = '${{ github.sha }}'
'Commit SHA' = '${{ inputs.commit-sha }}'
'Workflow name' = '${{ github.workflow }}'
'Workflow run URL' = 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
}
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/checkout/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
fetch-depth:
description: Number of commits to fetch. 0 indicates all history for all branches and tags.
default: 1
submodules:
description: >
Whether to checkout submodules - `true` to checkout submodules or `recursive` to recursively checkout submodules.
default: recursive

runs:
using: composite
Expand All @@ -40,7 +44,7 @@ runs:
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
submodules: recursive
submodules: ${{ inputs.submodules }}
token: ${{ env.CHECKOUT_TOKEN }}
path: ${{ inputs.path }}
fetch-depth: ${{ inputs.fetch-depth }}
22 changes: 22 additions & 0 deletions .github/actions/create-timestamp/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Create Timestamp
description: Create a timestamp in ISO 8601 format for use in tags (replaces ":" with "." for use in git tags).
runs:
using: composite
steps:
- name: Get Timestamp
id: get-timestamp
shell: pwsh
run: |
# Get the current timestamp in the ISO 8601 format but replace ":" with "." because we can't use ":" in tags.
$timestamp = ((Get-Date).ToUniversalTime().GetDateTimeFormats('s')[0])
$timestampTag = $timestamp -replace ":", "-"
echo "timestamp=$timestamp" >> $env:GITHUB_OUTPUT
echo "timestamp-tag=$timestampTag" >> $env:GITHUB_OUTPUT

outputs:
timestamp:
description: The generated timestamp
value: ${{ steps.get-timestamp.outputs.timestamp }}
timestamp-tag:
description: The generated timestamp parsed as a usable git tag
value: ${{ steps.get-timestamp.outputs.timestamp-tag }}
2 changes: 1 addition & 1 deletion .github/actions/precompile-orchard1-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ runs:
if: inputs.repository != ''
# Using the official checkout action directly, because our wrapper action doesn't have most of the parameters we
# need here. We only need those parameters for this action though.
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.checkout-ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish-nuget/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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
15 changes: 15 additions & 0 deletions .github/actions/release-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ 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 }}
releaseName:
description: An optional name for the release. If this is omitted the tag will be used.
required: false
default: ''

outputs:
id:
Expand All @@ -49,3 +61,6 @@ 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
name: ${{ inputs.name }}
24 changes: 24 additions & 0 deletions .github/actions/remove-old-latest-tags/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Remove Old Latest Tags
description: >
Removes the old prefix/latest tag so that a new one can be set.

inputs:
tag-prefix:
description: The prefix for the tag we are removing.
required: true

runs:
using: composite
steps:
- name: Delete Latest Tag
shell: pwsh
run: |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]'
git fetch --tags
$latestTag = (git tag --list '${{ inputs.tag-prefix }}/latest')
if ($latestTag)
{
git tag --delete '${{ inputs.tag-prefix }}/latest'
git push origin ':refs/tags/${{ inputs.tag-prefix }}/latest'
}
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
ENVIRONMENT_VARIABLES_JSON: ${{ secrets.ENVIRONMENT_VARIABLES_JSON }}

- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.repository-ref }}
Expand Down Expand Up @@ -270,7 +270,7 @@ jobs:

- name: Tests
if: inputs.test-disable == 'false'
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@dev
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@issue/OSOE-861
with:
blame-hang-timeout: ${{ inputs.blame-hang-timeout }}
build-directory: ${{ inputs.build-directory }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
Write-Output $message

- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.repository-ref }}
Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:

- name: Tests
if: inputs.test-disable == 'false'
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@dev
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@issue/OSOE-861
with:
blame-hang-timeout: ${{ inputs.blame-hang-timeout }}
build-directory: ${{ inputs.build-directory }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
Write-Output '::warning::This workflow is deprecated. Use build-and-test-dotnet instead, that can also execute tests.'

- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-orchard1-to-azure-app-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:

- name: Add Azure Application Insights Release Annotation
if: ${{ inputs.application-insights-resource-id != '' }}
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@dev
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@issue/OSOE-861
with:
release-name: 'Deploy #${{ github.run_number }} to ${{ inputs.slot-name }}'
application-insights-resource-id: ${{ inputs.application-insights-resource-id }}
Expand Down
29 changes: 27 additions & 2 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,14 @@ 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
default: staging
required: false
description: >
The prefix to use for the tag. If not set, 'staging' will be used as the prefix. The tag will be in the
format of "<prefix>/latest" and "<prefix>/<timestamp>". This is used for tracking what's deployed, where and
when by tagging the deployed commit.

jobs:
deploy:
Expand All @@ -144,7 +152,7 @@ jobs:
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand Down Expand Up @@ -227,11 +235,28 @@ jobs:
restart: false
clean: false

- name: Create Timestamp
id: create-timestamp
uses: Lombiq/GitHub-Actions/.github/actions/create-timestamp@issue/OSOE-861

- name: Add Azure Application Insights Release Annotation
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@dev
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@issue/OSOE-861
with:
release-name: 'Deploy #${{ github.run_number }} to ${{ inputs.slot-name }}'
application-insights-resource-id: ${{ inputs.application-insights-resource-id }}
timestamp: ${{ steps.create-timestamp.outputs.timestamp }}

- name: Remove Old Latest Tags
uses: Lombiq/GitHub-Actions/.github/actions/remove-old-latest-tags@issue/OSOE-861
with:
tag-prefix: ${{ inputs.tag-prefix }}

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

- name: Start Web App Slot
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown-lint-this-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
markdown-linting:
name: Markdown Linting
uses: Lombiq/GitHub-Actions/.github/workflows/markdown-lint.yml@dev
uses: Lombiq/GitHub-Actions/.github/workflows/markdown-lint.yml@issue/OSOE-861
with:
globs: '**/*.{md,markdown};!License.md'
separator: ;
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/msbuild-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
ENVIRONMENT_VARIABLES_JSON: ${{ secrets.ENVIRONMENT_VARIABLES_JSON }}

- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.repository-ref }}
Expand All @@ -162,7 +162,7 @@ jobs:

- name: Tests
if: inputs.test-disable == 'false'
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@dev
uses: Lombiq/GitHub-Actions/.github/actions/test-dotnet@issue/OSOE-861
with:
build-directory: ${{ inputs.build-directory }}
dotnet-test-process-timeout: ${{ inputs.dotnet-test-process-timeout }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
ENVIRONMENT_VARIABLES_JSON: ${{ secrets.ENVIRONMENT_VARIABLES_JSON }}

- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand All @@ -91,7 +91,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
2 changes: 1 addition & 1 deletion .github/workflows/reset-azure-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:

- name: Add Azure Application Insights Release Annotation
if: ${{ inputs.application-insights-resource-id != '' }}
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@dev
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@issue/OSOE-861
with:
release-name: 'Reset #${{ github.run_number }} from ${{ inputs.source-slot-name }} to ${{ inputs.destination-slot-name }}'
application-insights-resource-id: ${{ inputs.application-insights-resource-id }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling-this-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
spelling:
name: Spelling
uses: Lombiq/GitHub-Actions/.github/workflows/spelling.yml@dev
uses: Lombiq/GitHub-Actions/.github/workflows/spelling.yml@issue/OSOE-861
with:
additional-dictionaries: |
cspell:companies/src/companies.txt
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
uses: Lombiq/GitHub-Actions/.github/actions/checkout@issue/OSOE-861
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

Expand Down
Loading