Repository navigation
75 lines (72 loc) · 2.72 KB
/
Copy pathruby_app_release.yml
File metadata and controls
75 lines (72 loc) · 2.72 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Release Docker Version
on:
workflow_call:
secrets:
# Registry arguments.
# Must supply set of arguments for at least 1 registry.
# Artifact Registry arguments
ARTIFACT_REGISTRY:
description: 'Artifact Registry address to which to publish (leave blank to not publish)'
required: false
ARTIFACT_REGISTRY_JSON_KEY:
description: 'Key for publishing to Artifact Registry'
required: false
jobs:
push:
#
# Build the Docker image artifact and deliver it.
#
runs-on: ubuntu-latest
steps:
# Checkout code needed to build docker image.
- uses: actions/checkout@v3
# Parse GitHub repository name for use in constructing docker image names.
- name: Parse Repo Name
id: parse_repo_name
run: |
echo "repo_name=$( echo '${{ github.repository }}' | awk -F '/' '{print $2}' )" >> $GITHUB_OUTPUT
# Make the docker fields for Artifact Registry if we're pushing to it.
- name: Construct Artifact Registry fields
env:
ARTIFACT_REGISTRY: ${{ secrets.ARTIFACT_REGISTRY }}
if: ${{ env.ARTIFACT_REGISTRY }}
run: |
echo "ARTIFACT_REGISTRY_IMAGE_NAME=${{ secrets.ARTIFACT_REGISTRY }}/${{ github.repository }}" >> $GITHUB_ENV
# Create docker image meta data. Docker tags include the Git tag itself and the sematic version parsing of that tag if possible.
- name: Docker release meta
id: release
uses: docker/metadata-action@v4
with:
images: |
${{ env.ARTIFACT_REGISTRY_IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
# Login to Artifact Registry if we're pushing to it.
- name: Login to Artifact Registry
env:
ARTIFACT_REGISTRY_JSON_KEY: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
if: ${{ env.ARTIFACT_REGISTRY_JSON_KEY }}
uses: docker/login-action@v2
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
# Setup Docker builder needed to build multi-architectural images.
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# Build and push the image.
- name: Build and Push to Artifact Registry
uses: docker/build-push-action@v3
with:
push: true
context: .
file: Dockerfile
platforms: linux/amd64
build-args: |
VERSION=${{ steps.release.outputs.version }}
tags: ${{ steps.release.outputs.tags }}
labels: ${{ steps.release.outputs.labels }}