-
Notifications
You must be signed in to change notification settings - Fork 11
73 lines (69 loc) · 2.8 KB
/
docker-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
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
# yaml file to run automate docker builds.
# currently this is in testing so will only build docker images with test-${VERSION] as the tag
name: Automate Docker Image Build & Push to Quay.io Registry CI
on:
pull_request:
branches:
- master
- main
types:
- closed
#ideally would only have builds on closed PRs that have been accepted.
#- open
push:
branches:
- master
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_ID }}
password: ${{ secrets.QUAY_PW }}
-
name: Find Changed/Added Files
uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
-
name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v24
with:
files:
containers/**/Dockerfile
-
name: List all changed files
id: list-files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
TAG_NAME=`cut -d / -f 2 <<< $file`
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
done
REPO_NAME=`echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]'`
NORMALIZED=`echo ${REPO_NAME//[%&*<>~-=+]/_}`
echo "NORMALIZED=$NORMALIZED" >> $GITHUB_ENV
-
name: Get current date # get the date of the build
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')"
-
name: Building & Pushing Docker Image
run: |
cd containers/$TAG_NAME || exit
VERSION=$(cat VERSION)
CONTAINER_VERSION=${VERSION}_${{ steps.date.outputs.date }}
docker build . --tag quay.io/pawsey/${NORMALIZED}_${TAG_NAME}:${CONTAINER_VERSION}
docker push quay.io/pawsey/${NORMALIZED}_${TAG_NAME}:${CONTAINER_VERSION}
-
name: Setting Repository Public
run: |
curl -s -X POST -H "Authorization: Bearer ${{ secrets.ROBOT_ACCESS_TOKEN }}" -H "Content-Type: application/json" -d '{"visibility":"public"}' "https://quay.io//api/v1/repository/<your organization>/${NORMALIZED}_${TAG_NAME}/changevisibility"
#for repository in $(curl -s -X GET -H "Authorization: Bearer ${{ secrets.ROBOT_ACCESS_TOKEN }}" "https://quay.io/api/v1/repository?namespace=<your organization>" | jq -r '.repositories[].name' | sort); do
# curl -s -X POST -H "Authorization: Bearer ${{ secrets.ROBOT_ACCESS_TOKEN }}" -H "Content-Type: application/json" -d '{"visibility":"public"}' "https://quay.io//api/v1/repository/<your organization>/$repository/changevisibility"
#done