-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (46 loc) · 2.13 KB
/
build-publish-image.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
# This is an example GitHub action that will build and publish a Docker image to DockerHub
# You need to add the following secrets to your GitHub Repository or Organization to make this work
# - DOCKER_USERNAME: The username of the DockerHub account. E.g. parity
# - DOCKER_TOKEN: Access token for DockerHub, see https://docs.docker.com/docker-hub/access-tokens/. E.g. VVVVVVVV-WWWW-XXXXXX-YYYY-ZZZZZZZZZ
# The following are setup as an environment variable below
# - DOCKER_REPO: The unique name of the DockerHub repository. E.g. parity/polkadot
name: Build & Publish Docker Image
# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the main branch
# push:
# branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
environment:
required: false
description: Specify environment to run on.
# Set an environment variable (that can be overriden) for the Docker Repo
env:
DOCKER_REPO: societal/website
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out the repo
uses: actions/[email protected]
# Login to Docker hub using the credentials stored in the repository secrets
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# Get the commit short hash, to use as the rev
- name: Calculate rev hash
id: rev
run: echo "value=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# Get the tag if available to use as a docker tag
- name: Set tag if available
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Docker Build Publish
uses: ./.github/actions/docker-build-publish