Skip to content

Commit 2a4cbb1

Browse files
Merge pull request #48 from hyperledger/actions
Add GitHub action to build commits to main
2 parents ac335c1 + 23c26fe commit 2a4cbb1

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

.github/workflows/docker_main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Docker Main Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Set build tag
15+
id: build_tag_generator
16+
run: |
17+
RELEASE_TAG=$(curl https://api.github.com/repos/hyperledger/firefly-dataexchange-https/releases/latest -s | jq .tag_name -r)
18+
BUILD_TAG=$RELEASE_TAG-$(date +"%Y%m%d")-$GITHUB_RUN_NUMBER
19+
echo ::set-output name=BUILD_TAG::$BUILD_TAG
20+
21+
- name: Build
22+
run: |
23+
docker build \
24+
--label commit=$GITHUB_SHA \
25+
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
26+
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
27+
--tag ghcr.io/hyperledger/firefly-dataexchange-https:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .
28+
29+
- name: Tag release
30+
run: docker tag ghcr.io/hyperledger/firefly-dataexchange-https:${{ steps.build_tag_generator.outputs.BUILD_TAG }} ghcr.io/hyperledger/firefly-dataexchange-https:head
31+
32+
- name: Push docker image
33+
run: |
34+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
35+
docker push ghcr.io/hyperledger/firefly-dataexchange-https:${{ steps.build_tag_generator.outputs.BUILD_TAG }}
36+
37+
- name: Push head tag
38+
run: |
39+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
40+
docker push ghcr.io/hyperledger/firefly-dataexchange-https:head

.github/workflows/docker.yml renamed to .github/workflows/docker_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Docker
22

33
on:
44
release:
5-
types: [published, prereleased]
5+
types: [released, prereleased]
66

77
jobs:
88
docker:
@@ -14,7 +14,7 @@ jobs:
1414
run: docker build -t ghcr.io/hyperledger/firefly-dataexchange-https:${GITHUB_REF##*/} .
1515

1616
- name: Tag release
17-
if: github.event.action == 'published'
17+
if: github.event.action == 'released'
1818
run: docker tag ghcr.io/hyperledger/firefly-dataexchange-https:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly-dataexchange-https:latest
1919

2020
- name: Push docker image
@@ -23,7 +23,7 @@ jobs:
2323
docker push ghcr.io/hyperledger/firefly-dataexchange-https:${GITHUB_REF##*/}
2424
2525
- name: Push latest tag
26-
if: github.event.action == 'published'
26+
if: github.event.action == 'released'
2727
run: |
2828
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
2929
docker push ghcr.io/hyperledger/firefly-dataexchange-https:latest

0 commit comments

Comments
 (0)