Skip to content

Commit 715295f

Browse files
authored
Run non-deploy portions of release workflow when CI workflow runs (#1529)
* Run non-deploy portions of release workflow when CI workflow runs * Add step that verifies release artifact counts * Don't run release for Dependabot * Skip building Windows image if not a tag
1 parent 23f82ad commit 715295f

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
name: Release
22
on:
33
push:
4+
branches:
5+
- master
6+
- release-*
47
tags:
58
- '[0-9]+.[0-9]+.[0-9]+'
69
- '[0-9]+.[0-9]+.[0-9]+-*'
10+
pull_request:
711
workflow_dispatch:
812
env:
913
DOTNET_NOLOGO: true
1014
jobs:
1115
release:
16+
if: ${{ github.actor != 'dependabot[bot]' }}
1217
runs-on: windows-2022
1318
outputs:
1419
version: ${{ steps.save-version.outputs.version }}
1520
steps:
21+
- name: Check for secrets
22+
env:
23+
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
24+
shell: pwsh
25+
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
1626
- name: Checkout
1727
uses: actions/[email protected]
1828
with:
@@ -68,7 +78,28 @@ jobs:
6878
assets/*
6979
nugets/*
7080
retention-days: 1
81+
- name : Verify release artifact counts
82+
shell: pwsh
83+
run: |
84+
$assetsCount = (Get-ChildItem -Recurse -File assets).Count
85+
$nugetsCount = (Get-ChildItem -Recurse -File nugets).Count
86+
87+
$expectedAssetsCount = 1
88+
$expectedNugetsCount = 1
89+
90+
if ($assetsCount -ne $expectedAssetsCount)
91+
{
92+
Write-Host Assets: Expected $expectedAssetsCount but found $assetsCount
93+
exit -1
94+
}
95+
96+
if ($nugetsCount -ne $expectedNugetsCount)
97+
{
98+
Write-Host Nugets: Expected $expectedNugetsCount but found $nugetsCount
99+
exit -1
100+
}
71101
- name: Deploy
102+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
72103
uses: Particular/[email protected]
73104
with:
74105
octopus-deploy-api-key: ${{ secrets.OCTOPUS_DEPLOY_API_KEY }}
@@ -86,6 +117,11 @@ jobs:
86117
dockerfile: dockerfile.nginx
87118
fail-fast: false
88119
steps:
120+
- name: Check for secrets
121+
env:
122+
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
123+
shell: pwsh
124+
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
89125
- name: Checkout
90126
uses: actions/[email protected]
91127
- name: Add NODE_OPTIONS to ENVVARS # Must do this after checkout as checkout uses node v16 which will cause this to fail
@@ -103,13 +139,16 @@ jobs:
103139
$filename = "src/ServicePulse.Host/app/js/app.constants.js"
104140
(Get-Content $filename).replace("1.2.0", "${{ needs.release.outputs.version }}") | Set-Content $filename
105141
shell: pwsh
142+
- name: Build Docker image
143+
if: ${{ matrix.image-name == 'servicepulse' || (github.event_name == 'push' && github.ref_type == 'tag') }}
144+
run: docker build -t particular/${{ matrix.image-name }}:${{ needs.release.outputs.version }} -f ${{ matrix.dockerfile }} .
145+
working-directory: src
106146
- name: Login to Docker Hub
147+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
107148
uses: docker/[email protected]
108149
with:
109150
username: ${{ secrets.DOCKERHUB_USERNAME }}
110151
password: ${{ secrets.DOCKERHUB_TOKEN }}
111-
- name: Build Docker image
112-
run: docker build -t particular/${{ matrix.image-name }}:${{ needs.release.outputs.version }} -f ${{ matrix.dockerfile }} .
113-
working-directory: src
114152
- name: Push Docker image
153+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
115154
run: docker push particular/${{ matrix.image-name }}:${{ needs.release.outputs.version }}

0 commit comments

Comments
 (0)