-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (96 loc) · 3.11 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
name: Build Image & Deploy
on:
push:
branches:
- main
concurrency: cd
jobs:
build:
# runs-on: self-hosted
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
if: "!contains(github.event.head_commit.message, '#skip-ci')"
steps:
- name: Check Out Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Dry incremement patch version
id: tag-dry-run
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
WITH_V: true
DRY_RUN: true
- name: Set version for later
run: |
echo "Increnting version with '${{ steps.tag-dry-run.outputs.part }}' to '${{ steps.tag-dry-run.outputs.new_tag }}' from '${{ steps.tag-dry-run.outputs.tag }}'"
tag=${{ steps.tag-dry-run.outputs.new_tag }}
version=$(echo "$tag" | cut -b 2-)
echo "version=$version" >> $GITHUB_ENV
- name: Set npm version
uses: reedyuk/npm-version@1.1.1
with:
version: ${{ env.version }}
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/helldivers2-bot
tags: |
type=semver,pattern={{major}},value=${{ env.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.version }}
- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
endpoint: builders
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Increment patch version
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: none
deploy:
# runs-on: self-hosted
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
if: "!contains(github.event.head_commit.message, '#skip-ci')"
needs: ['build'] # always run after build step
steps:
- name: Check Out Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: steebchen/kubectl@v2.0.0
with:
config: ${{ secrets.KUBECONFIG }}
command: rollout restart deployment/helldivers2-bot-deployment -n=helldivers2