-
Notifications
You must be signed in to change notification settings - Fork 11
73 lines (65 loc) · 2.06 KB
/
build-sw-container.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
name: Build and Push Docker image
on:
push:
branches: ['master']
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:
jobs:
make-date-tag:
runs-on: ubuntu-latest
if: startsWith(github.repository, 'opensciencegrid/')
outputs:
dtag: ${{ steps.mkdatetag.outputs.dtag }}
steps:
- name: make date tag
id: mkdatetag
run: echo "::set-output name=dtag::$(date +%Y%m%d-%H%M)"
build:
runs-on: ubuntu-latest
needs: [make-date-tag]
if: startsWith(github.repository, 'opensciencegrid/')
strategy:
fail-fast: False
matrix:
repo: ['release']
steps:
- uses: actions/checkout@v2
- name: Generate tag list
id: generate-tag-list
env:
REPO: ${{ matrix.repo }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
docker_repo=${GITHUB_REPOSITORY/opensciencegrid\/docker-/opensciencegrid/}
tag_list=()
for registry in hub.opensciencegrid.org docker.io; do
for image_tag in "$REPO" "$REPO-$TIMESTAMP"; do
tag_list+=("$registry/$docker_repo":"$image_tag")
done
done
# This causes the tag_list array to be comma-separated below,
# which is required for build-push-action
IFS=,
echo "::set-output name=taglist::${tag_list[*]}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to OSG Harbor
uses: docker/login-action@v1
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
push: true
build-args: BASE_YUM_REPO=${{ matrix.repo }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"