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
71 lines (61 loc) · 2.41 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 Build Push (Web3)
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-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:
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:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}