-
-
Notifications
You must be signed in to change notification settings - Fork 65
38 lines (30 loc) · 1.21 KB
/
build-and-push-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
name: Build and publish image to Docker Hub
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Github stores the current tag in an enviroment variable (GITHUB_REF) in the format /refs/tags/TAG_NAME.
# Using shell parameter expansion, we extract the TAG_NAME. Also, it seems we cannot use shell tricks
# directly in the with block, so doing it in a separate step and then fetching its output when needed.
- name: Get the tag name
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- name: Docker Setup Buildx
uses: docker/[email protected]
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
build-args: GIT_COMMIT_SHA=${{ steps.get_tag.outputs.TAG }}
cache-from: metabrainz/acousticbrainz:cache
cache-to: metabrainz/acousticbrainz:cache
push: true
tags: metabrainz/acousticbrainz:${{ steps.get_tag.outputs.TAG }}
target: acousticbrainz-prod