-
Notifications
You must be signed in to change notification settings - Fork 4
59 lines (51 loc) · 1.68 KB
/
docker-ci.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
name: docker-ci
on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
DOCKER_REPOSITORY: edgelevel
DOCKER_IMAGE_NAME: lastpass-operator
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
# makes sure it doesn't finish the minutes quota if stalls
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
# extracts tag from ref, returns semver tag or sha suffix
- name: Get Docker tag
id: get-docker-tag
env:
GITHUB_REF: ${{ github.ref }}
COMMIT_SHA: ${{ github.sha }}
run: |
if [[ ${{ github.ref_type }} == "tag" ]]; then
echo "tag=${GITHUB_REF#refs/tags/v}" >> ${GITHUB_OUTPUT}
else
echo "tag=${COMMIT_SHA:0:7}" >> ${GITHUB_OUTPUT}
fi
- name: Output Docker tag
run: echo ${{ steps.get-docker-tag.outputs.tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# gh-actions-rw
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push [${{ env.DOCKER_IMAGE_NAME }}]
uses: docker/build-push-action@v6
with:
build-args: |
VERSION_COMMIT=${{ steps.get-docker-tag.outputs.tag }}
# if false it will only build
push: true
tags: |
${{ env.DOCKER_REPOSITORY }}/${{ env.DOCKER_IMAGE_NAME }}:latest
${{ env.DOCKER_REPOSITORY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.get-docker-tag.outputs.tag }}