forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (88 loc) · 3.26 KB
/
build-push-sqs.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
# This workflow pushes new docker images to osmolabs/sqs-dev on these events:
# 2. Every new commit to the v20.x or v21.x,
# tag with: sqs-v[0-9]+.[0-9]+.[0-9],
# or manually triggered workflow_dispatch event.
# `osmolabs/sqs-dev:{SHORT_SHA}-$(date +%s)` is pushed.
# All the images above have support for linux/amd64 (not linux/arm64)
# All the images are based on an alpine image for easy debugging.
name: Build and Push SQS Images
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
required: true
default: 'v20.x'
push:
tags:
- sqs-v[0-9]+.[0-9]+.[0-9]+
branches:
- "v[0-9]**"
env:
RUNNER_BASE_IMAGE_ALPINE: alpine:3.17
SQS_DEV_IMAGE_REPOSITORY: osmolabs/sqs-dev
SQS_PROD_IMAGE_REPOSITORY: osmolabs/sqs
jobs:
docker:
runs-on: self-hosted
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Find go version
run: |
GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
- name: Create Docker Image Tag for release candidate on Tag Push
if: startsWith(github.ref, 'refs/tags/sqs-v')
run: |
GITHUB_TAG=${{ github.ref_name }}
echo "DOCKER_IMAGE_TAG=${GITHUB_TAG#v}" >> $GITHUB_ENV
echo "OSMOSIS_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Create Docker Image Tag for v20.x or v21.x branch or workflow_dispatch
if: |
github.ref == 'refs/heads/v20.x' ||
(github.ref == 'refs/heads/v21.x') ||
(github.event_name == 'workflow_dispatch')
run: |
SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8)
echo "DOCKER_IMAGE_TAG=${SHORT_SHA}-$(date +%s)" >> $GITHUB_ENV
echo "OSMOSIS_VERSION=$SHORT_SHA" >> $GITHUB_ENV
- name: Build and Push Docker Images Dev
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }}
GIT_VERSION=${{ env.OSMOSIS_VERSION }}
GIT_COMMIT=${{ github.sha }}
tags: |
${{ env.SQS_DEV_IMAGE_REPOSITORY }}:${{ env.DOCKER_IMAGE_TAG }}
${{ env.SQS_DEV_IMAGE_REPOSITORY }}:sqs-latest
- name: Build and Push Docker Images Prod
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }}
GIT_VERSION=${{ env.OSMOSIS_VERSION }}
GIT_COMMIT=${{ github.sha }}
tags: |
${{ env.SQS_PROD_IMAGE_REPOSITORY }}:${{ env.DOCKER_IMAGE_TAG }}
${{ env.SQS_PROD_IMAGE_REPOSITORY }}:sqs-latest