-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (127 loc) · 4.14 KB
/
build.yml
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
name: Build
on:
push:
branches: [ main ]
pull_request:
merge_group:
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
showConfig: true
configFilePath: ./GitVersion.yml
- name: Display SemVer
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
release:
runs-on: ubuntu-latest
needs: version
if: github.event_name != 'pull_request'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.version.outputs.version }}
release_name: fireapp-${{ needs.version.outputs.version }}
draft: false
prerelease: false
- name: Create Backend ZIP deployment package
run: zip -r fireapp-${{ needs.version.outputs.version }}.zip . [email protected];
- name: Upload ZIP as Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./fireapp-${{ needs.version.outputs.version }}.zip
asset_name: fireapp-${{ needs.version.outputs.version }}.zip
asset_content_type: application/zip
docker:
runs-on: ubuntu-latest
needs: version
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Lowercase Repository
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV}
env:
REPOSITORY: '${{ github.repository }}'
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.REPOSITORY_LC }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
if [[ "${{ github.event_name != 'pull_request' }}" == "true" ]]; then
echo "TAGS<<EOF" >> $GITHUB_ENV
echo -e "$ATAG\nghcr.io/${{ env.REPOSITORY_LC }}:latest\nghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "TAGS<<EOF" >> $GITHUB_ENV
echo "ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
id: tag
env:
ATAG: ${{ steps.meta.outputs.tags }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64, linux/arm64, linux/riscv64, linux/arm/v7, linux/arm/v6
push: true
tags: |
${{ env.TAGS }}
call_test:
needs:
- docker
- version
uses: ./.github/workflows/test.yml
with:
version: ${{ needs.version.outputs.version }}