-
Notifications
You must be signed in to change notification settings - Fork 27
169 lines (145 loc) · 5.13 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: aihub
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCS_IMAGE_NAME: aihub-prepdocs
AIHUB_ARTIFACT_NAME: aihub-tf-module
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.x'
include-prerelease: true
- name: Setup MinVer
run: |
dotnet tool install --global minver-cli --version 4.3.0
- name: Calculate Version
run: |
echo "MINVERVERSIONOVERRIDE=$($HOME/.dotnet/tools/minver -t v. -m 1.0 -p preview)" >> $GITHUB_ENV
- name: Build with dotnet
run: dotnet build --configuration Release
working-directory: './src/AIHub'
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
working-directory: './src/AIHub'
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
- name: Login to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Lower case REPO
run: |
echo "GITHUB_REPOSITORY_LOWER_CASE=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Build and push Docker image for AIHub
uses: docker/build-push-action@v3
with:
context: ./src/AIHub/
file: ./src/AIHub/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY_LOWER_CASE }}/aihub:${{ env.MINVERVERSIONOVERRIDE }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract metadata (tags, labels) for prep-docs Docker
id: meta-docs
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.DOCS_IMAGE_NAME }}
- name: Build and push Docker image for prep-docs
uses: docker/build-push-action@v3
with:
context: ./src/prepdocs/
file: ./src/prepdocs/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY_LOWER_CASE }}/${{ env.DOCS_IMAGE_NAME }}:${{ env.MINVERVERSIONOVERRIDE }}
labels: ${{ steps.meta-docs.outputs.labels }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.AIHUB_ARTIFACT_NAME }}
path: |
./infra/modules/
./infra/*.tf
./infra/*.md
release:
name: Create Release
needs: build
if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions: write-all
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: release
uses: actions/create-release@v1
id: create_release
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.MINVERVERSIONOVERRIDE }}
body: ${{ steps.changelog.outputs.clean_changelog }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ github.token }}
publish:
name: Publish binaries
needs: release
permissions: write-all
if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v')
env:
ARTIFACT_DIR: ${{ github.workspace }}/release
PROJECT_NAME: aihub
runs-on: ubuntu-latest
steps:
- name: download artifacts - ${{ env.AIHUB_ARTIFACT_NAME }}
uses: actions/download-artifact@v3
with:
name: ${{ env.AIHUB_ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.AIHUB_ARTIFACT_NAME }}
- name: Creating Zip
run: zip -r ${{ env.AIHUB_ARTIFACT_NAME }}.zip ${{ env.ARTIFACT_DIR }}/${{ env.AIHUB_ARTIFACT_NAME }}/*
- name: upload artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ env.AIHUB_ARTIFACT_NAME }}.zip
asset_name: ${{ env.AIHUB_ARTIFACT_NAME }}.zip
asset_content_type: application/octet-stream