Skip to content

Commit b57cc00

Browse files
committed
add build-container workflow (SOFTWARE-5154)
1 parent 6209ddd commit b57cc00

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build and Push Docker image
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
repository_dispatch:
7+
types:
8+
- dispatch-build
9+
workflow_dispatch:
10+
11+
jobs:
12+
make-date-tag:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.repository, 'opensciencegrid/')
15+
outputs:
16+
dtag: ${{ steps.mkdatetag.outputs.dtag }}
17+
steps:
18+
- name: make date tag
19+
id: mkdatetag
20+
run: echo "::set-output name=dtag::$(date +%Y%m%d-%H%M)"
21+
22+
build:
23+
runs-on: ubuntu-latest
24+
needs: [make-date-tag]
25+
if: startsWith(github.repository, 'opensciencegrid/')
26+
strategy:
27+
fail-fast: False
28+
matrix:
29+
repo: ['latest']
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Generate tag list
34+
id: generate-tag-list
35+
env:
36+
REPO: ${{ matrix.repo }}
37+
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
38+
run: |
39+
#docker_repo=${GITHUB_REPOSITORY/opensciencegrid\/docker-/opensciencegrid/}
40+
docker_repo=opensciencegrid/comanage-utils
41+
tag_list=()
42+
for registry in hub.opensciencegrid.org docker.io; do
43+
for image_tag in "$REPO" "$REPO-$TIMESTAMP"; do
44+
tag_list+=("$registry/$docker_repo":"$image_tag")
45+
done
46+
done
47+
# This causes the tag_list array to be comma-separated below,
48+
# which is required for build-push-action
49+
IFS=,
50+
echo "::set-output name=taglist::${tag_list[*]}"
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v1
54+
55+
- name: Log in to Docker Hub
56+
uses: docker/login-action@v1
57+
with:
58+
username: ${{ secrets.DOCKER_USERNAME }}
59+
password: ${{ secrets.DOCKER_PASSWORD }}
60+
61+
- name: Log in to OSG Harbor
62+
uses: docker/login-action@v1
63+
with:
64+
registry: hub.opensciencegrid.org
65+
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
66+
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
67+
68+
- name: Build and push Docker images
69+
uses: docker/[email protected]
70+
with:
71+
context: .
72+
push: true
73+
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
74+

0 commit comments

Comments
 (0)