This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
74 lines (63 loc) · 2.5 KB
/
docker-publish-indexer.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
name: Docker Build Push (Indexer)
on:
push:
branches: ["main", '*-rc*']
tags: ["v*.*.*"]
workflow_dispatch:
env:
# Use ghcr.io only
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: godwoken-web3-indexer-prebuilds
jobs:
docker-build-push:
runs-on: ubuntu-latest
# If you specify the access for any of these scopes, all of those that are not specified are set to none.
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
# GitHub automatically creates a unique GITHUB_TOKEN secret to use in this workflow.
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
- name: Get Current Commit Id
id: commit
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: New Commit Build => Build and push commit image to ${{ env.REGISTRY }}
if: ${{ github.ref_type != 'tag' }}
uses: docker/build-push-action@v2
with:
file: docker/indexer/Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-${{ steps.commit.outputs.sha_short }}
labels: ${{ steps.meta.outputs.labels }}
# Build and push Docker image with Buildx (don't push on PR)
# only for new tag
- name: Official Release Build => Build and push tag image to ${{ env.REGISTRY }}
if: ${{ startsWith(github.ref, 'refs/tags') }}
uses: docker/build-push-action@v2
with:
file: docker/indexer/Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}