-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (95 loc) · 3.49 KB
/
publish.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: "Bulid & Publish Docker Image"
on:
workflow_call:
inputs:
aws_region:
description: "AWS Region"
required: false
default: "eu-west-1"
type: string
target:
description: "Target"
required: false
default: "image"
type: string
secrets:
aws_access_key_id:
required: true
aws_secret_access_key:
required: true
epi_gpr_access_token:
required: false
outputs:
deploy:
description: "The deployment environment"
value: ${{ jobs.publish.outputs.deploy }}
key:
description: "The Ansible to use in deployment"
value: ${{ jobs.publish.outputs.key }}
tag:
description: "The tag of the built docker image"
value: ${{ jobs.publish.outputs.tag }}
jobs:
publish:
name: "Build & Upload Docker Image to ECR"
runs-on: ubuntu-20.04
outputs:
deploy: ${{ steps.mapper.outputs.deploy }}
key: ${{ steps.mapper.outputs.key }}
publish: ${{ steps.mapper.outputs.publish }}
tag: ${{ steps.gittag.outputs.tag }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Record desired ruby version"
id: ruby
shell: bash
run: |
[ -f .ruby-version ] && echo version=$(cat .ruby-version) | tee -a $GITHUB_OUTPUT || echo "version=" >> $GITHUB_OUTPUT
- name: "Setup ruby"
if: steps.ruby.outputs.version != ''
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ steps.ruby.outputs.version }}
- name: "Mapped deployment"
id: mapper
uses: "epimorphics/github-actions/mapper@v14"
- name: "Get image tag"
id: gittag
uses: "epimorphics/github-actions/generate-tag@v14"
- name: "Create image"
if: steps.mapper.outputs.image != ''
env:
AWS_ACCESS_KEY_ID: "${{ secrets.aws_access_key_id }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.aws_secret_access_key }}"
AWS_REGION: "${{ inputs.aws_region }}"
REPO: ${{ steps.mapper.outputs.image }}
shell: bash
run: |
PAT=${{ secrets.epi_gpr_access_token }} make ${{ inputs.target }}
- name: "Configure AWS Credentials"
if: ( steps.mapper.outputs.image != '' && steps.mapper.outputs.publish != '' && steps.gittag.outputs.tag != '' )
uses: "aws-actions/configure-aws-credentials@v4"
with:
aws-access-key-id: "${{ secrets.aws_access_key_id }}"
aws-secret-access-key: "${{ secrets.aws_secret_access_key }}"
aws-region: "${{ inputs.aws_region }}"
- name: "Login to Amazon ECR"
if: ( steps.mapper.outputs.image != '' && steps.mapper.outputs.publish != '' && steps.gittag.outputs.tag != '' )
id: "login-ecr"
uses: "aws-actions/amazon-ecr-login@v2"
with:
mask-password: 'true'
- name: "Create ECR area"
if: ( steps.mapper.outputs.image != '' && steps.mapper.outputs.publish != '' && steps.gittag.outputs.tag != '' )
uses: "epimorphics/github-actions/create-ecr-action@v14"
with:
image: "${{ steps.mapper.outputs.image }}/${{ steps.mapper.outputs.publish }}"
- name: "Publish image"
if: ( steps.mapper.outputs.image != '' && steps.mapper.outputs.publish != '' && steps.gittag.outputs.tag != '' )
env:
IMAGE: "${{ steps.mapper.outputs.image }}/${{ steps.mapper.outputs.publish }}"
TAG: "${{ steps.gittag.outputs.tag }}"
shell: bash
run: |
PAT=${{ secrets.epi_gpr_access_token }} make publish