-
Notifications
You must be signed in to change notification settings - Fork 9
48 lines (36 loc) · 1.35 KB
/
publish-container.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
name: Publish container image
on:
push:
tags: [ 'v*' ]
jobs:
publish-container:
name: Build and Push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to ghcr.io Docker registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute Docker container image addresses
run: |
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
DOCKER_TAG="${GITHUB_REF:11}"
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"
- name: 'Pull previous Docker container image: app:latest'
run: docker pull "${DOCKER_REPOSITORY}/app:latest" || true
- name: 'Build Docker container image: app:latest'
run: |
docker build \
--cache-from "${DOCKER_REPOSITORY}/app:latest" \
--tag "${DOCKER_REPOSITORY}/app:latest" \
--tag "${DOCKER_REPOSITORY}/app:${DOCKER_TAG}" \
.
- name: Push Docker container image app:latest"
run: docker push "${DOCKER_REPOSITORY}/app:latest"
- name: Push Docker container image app:v*"
run: docker push "${DOCKER_REPOSITORY}/app:${DOCKER_TAG}"