-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (134 loc) · 4.25 KB
/
push_docker.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
on:
push:
branches:
- main
- development
tags:
- '**'
jobs:
fetch_version:
name: Fetch version information
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
outputs:
version: ${{ steps.version.outputs.version }}
branch: ${{ steps.branch.outputs.branch }}
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: "Get hitster version"
id: version
shell: bash
run: |
cd client
npm i @corteks/gitversion
export VERSION="$(npm run version --silent)"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: branch
update_changelog:
needs: ["fetch_version"]
if: startsWith(github.ref, 'refs/tags') && !github.event_type != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
actions: read
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: 'main'
- name: Update changelog
uses: thomaseizinger/[email protected]
with:
version: ${{ needs.fetch_version.outputs.version }}
# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email [email protected]
- name: Commit changelog
run: |
git add CHANGELOG.md
git commit --message "Prepare release ${{ needs.fetch_version.outputs.version }}"
git push
push_release_container:
name: Push release container to Docker Hub
needs: ["update_changelog", "fetch_version"]
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: "Log in to Docker Hub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push Docker stable image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: tonironaldbarth/hitster:latest , tonironaldbarth/hitster:${{ needs.fetch_version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
HITSTER_VERSION=${{ needs.fetch_version.outputs.version }}
HITSTER_BRANCH=${{ needs.fetch_version.outputs.branch }}
push_development_container:
name: Push development container to Docker Hub
needs: ["fetch_version"]
if: startsWith(github.ref, 'refs/heads/development')
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: "Log in to Docker Hub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push Docker dev image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: tonironaldbarth/hitster:dev
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
HITSTER_VERSION=${{ needs.fetch_version.outputs.version }}
HITSTER_BRANCH=${{ needs.fetch_version.outputs.branch }}