-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.79 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
name: Build, test and publish packages
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
PACKAGE_VERSION: 1.3.0
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Version Variable
run: echo "PACKAGE_VERSION=$([ "$GITHUB_REF" = "refs/heads/main" ] && echo "$PACKAGE_VERSION" | tr "/" - || echo "$PACKAGE_VERSION-$GITHUB_HEAD_REF-$(date '+%Y%d%m%H%M%S')")" | tr "/" - >> $GITHUB_ENV
- name: Print Version Variable
run: echo "$PACKAGE_VERSION"
- name: Print GITHUB_HEAD_REF
run: echo "$GITHUB_HEAD_REF"
- name: Print GITHUB_REF
run: echo "$GITHUB_REF"
- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.3.4
with:
key: docker-${{ runner.os }}-${{ hashFiles('Dockerfile') }}
- name: Build the Docker image
run: |
docker build . --file Dockerfile \
--build-arg SONAR_TOKEN=${{ secrets.SONAR_TOKEN }} \
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--build-arg PACKAGE_VERSION=$PACKAGE_VERSION \
--build-arg NUGET_API_KEY=${{ secrets.NUGET_API_KEY }} \
--build-arg PULLREQUEST_TARGET_BRANCH=$GITHUB_BASE_REF \
--build-arg PULLREQUEST_BRANCH=$GITHUB_HEAD_REF \
--build-arg BRANCH_NAME=$GITHUB_REF_NAME \
--build-arg PULLREQUEST_ID=${{ github.event.number }} \
--tag artifacts:$(date +%s)
- name: Copy artifacts
run: containerId=$(docker create $(docker images --format='{{.ID}}' | head -1)) && docker cp $containerId:/artifacts/ ./artifacts
- name: Codecov
uses: codecov/codecov-action@v3.1.0
with:
# Comma-separated list of files to upload
files: # optional
# Directory to search for coverage reports.
directory: ./artifacts