-
Notifications
You must be signed in to change notification settings - Fork 5
52 lines (43 loc) · 1.47 KB
/
docker.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
name: build-docker-from-scratch-unconditionally
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
imageTag:
description: "The tag to be used for the images"
required: true
default: "latest"
env:
IMAGE_NAME: plant-map-digital-logbook
jobs:
# Builds the docker image if the corresponding files changed
build-docker:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Generate tags
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Save to env for later steps
echo "image_id=$IMAGE_ID" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GitHub container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push base image
uses: docker/build-push-action@v2
with:
push: true
file: .devcontainer/Dockerfile
tags: ${{ env.image_id}}:${{ github.event.inputs.imageTag }}
cache-from: type=registry,ref=${{ env.image_id }}:${{ github.event.inputs.imageTag }}
cache-to: type=inline