-
Notifications
You must be signed in to change notification settings - Fork 4
43 lines (37 loc) · 1.21 KB
/
build-push.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
name: Build and Push
# Run workflow on pushes to main branch or by manual dispatch
on:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
jobs:
build-publish:
runs-on: ubuntu-latest
name: Build and publish modulo image
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build image
run: |
docker build --tag modulo .
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Push latest image
if: ${{ github.event_name != 'release' }}
run: |
IMAGE_NAME="${{ github.repository }}:latest"
IMAGE_NAME="${IMAGE_NAME/_/-}"
docker tag modulo ghcr.io/"${IMAGE_NAME}"
docker push ghcr.io/"${IMAGE_NAME}"
- name: Push tagged image
if: ${{ github.event_name == 'release' }}
run: |
REF="${{ github.ref }}"
TAG="${REF##*/}"
IMAGE_NAME="${{ github.repository }}:${TAG}"
IMAGE_NAME="${IMAGE_NAME/_/-}"
docker tag modulo ghcr.io/"${IMAGE_NAME}"
docker push ghcr.io/"${IMAGE_NAME}"