-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 2.48 KB
/
docker-publish.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
name: Docker
on:
workflow_dispatch:
push:
# Publish `main` and `stable` as Docker `latest` image.
branches:
- 'main'
- '[0-9]+.X-stable'
# Publish `v1.2.3` tags as releases.
tags:
- 'v*'
- 'v[0-9]+.[0-9]+.[0-9]-stable'
env:
IMAGE_NAME: frinx/frinx-inventory-server
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set tag and hive token for latest image
if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/main')
run: |
echo "IMAGE_TAG=$(echo 'latest')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_MASTER_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for stable-latest image
if: github.ref_type == 'branch' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo 'stable-latest')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for stable-release image
if: github.ref_type == 'tag' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^v//' | sed -e 's/-stable//')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_RELEASE_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for release image
if: ${{ github.ref_type == 'tag' && !endsWith(github.ref, '-stable') }}
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^v//')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_MASTER_RELEASE_TOKEN }}" >> "$GITHUB_ENV"
- name: Build image
run: docker build --build-arg git_commit=$(git rev-parse HEAD) . --file Dockerfile --tag $IMAGE_NAME:${IMAGE_TAG}
- name: Log into docker hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Push image
run: docker push $IMAGE_NAME:${IMAGE_TAG}
- name: Hive publish
env:
SCHEMA_PATH: 'src/schema/api.graphql'
run: |
curl -sSL https://graphql-hive.com/install.sh | sh
hive schema:publish ${{ env.SCHEMA_PATH }} \
--registry.accessToken ${HIVE_TOKEN} \
--github