-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 3.22 KB
/
deploy_image.yaml
File metadata and controls
101 lines (85 loc) · 3.22 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
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
name: Reusable Image Deploy
on:
workflow_call:
inputs:
quayRepository:
description: The quay repository to upload the image to. The repository must belong to the dockstore quay organization.
required: true
type: string
dockerContext:
description: The Docker context containing the Docker file of the image to build and push.
required: false
default: .
type: string
buildArgs:
description: Build arguments used to build the Docker image
required: false
type: string
changelist:
description: 'Patch and pre-release metadata. Example: ".0-alpha.1"'
required: false
type: string
env:
DOCKER_IMAGE_NAME: quay.io/dockstore/${{ inputs.quayRepository }}
permissions:
id-token: write
contents: read
jobs:
deploy_image:
name: Deploy image to quay.io/dockstore/${{ inputs.quayRepository }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# Step that does that actual cache save and restore
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21.0.2+13.0.LTS'
distribution: 'adopt'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: docker_checksum_upload_from_github
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build without changelist
if: ${{ inputs.changelist == '' }}
run: ./mvnw -B clean install -DskipTests
- name: Build with changelist
if: ${{ inputs.changelist != '' }}
run: |
./mvnw -B clean install -DskipTests -Dchangelist=${{ inputs.changelist }}
- name: Set folder name
run: |
S3_FOLDER=${{ github.ref_name }}
echo "S3_FOLDER=${S3_FOLDER//\//_}" >> $GITHUB_ENV
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ${{ inputs.dockerContext }}
push: true
tags: '${{ env.DOCKER_IMAGE_NAME }}:${{ env.S3_FOLDER }}'
build-args: |
${{ inputs.buildArgs }}
- name: Create checksums
run: |
docker inspect ${{ env.DOCKER_IMAGE_NAME }}:${{ env.S3_FOLDER }} | grep -A 1 RepoDigests
docker inspect ${{ env.DOCKER_IMAGE_NAME }}:${{ env.S3_FOLDER }} | grep -A 1 RepoDigests | grep -oPm1 'sha256:\K\w+' > image-digest.txt
- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
- name: Copy checksum files
run: aws s3 cp image-digest.txt s3://${{ secrets.AWS_BUCKET }}/${{ env.S3_FOLDER }}-${{ steps.slug.outputs.sha7 }}/${{ inputs.quayRepository }}/image-digest.txt