Skip to content

Commit 3028c21

Browse files
committed
Adding support for building and publishing branches
1 parent 3215bd7 commit 3028c21

1 file changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/maven.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v1
1414

15+
- uses: nelonoel/branch-name@v1.0.1
16+
1517
- name: Set up JDK 1.8
1618
uses: actions/setup-java@v1
1719
with:
@@ -59,15 +61,17 @@ jobs:
5961
username: ${{ secrets.DOCKER_USERNAME }}
6062
password: ${{ secrets.DOCKER_PASSWORD }}
6163

62-
- name: Build and push
64+
- name: Main build and push
65+
if: github.ref == 'refs/heads/master'
6366
id: docker_build
6467
uses: docker/build-push-action@v2
6568
with:
6669
push: true
6770
build-args: VERSION=0.1.${{ github.run_number }}
6871
tags: octopussamples/randomquotesjava:0.1.${{ github.run_number }}
6972

70-
- name: Build Docker Package Info
73+
- name: Main build Docker build info
74+
if: github.ref == 'refs/heads/master'
7175
run: >-
7276
echo "{
7377
\"PackageId\": \"octopussamples/randomquotesjava\",
@@ -85,7 +89,8 @@ jobs:
8589
[{\"Id\":\"${{ github.sha }}\", \"LinkUrl\":\"https://github.com/OctopusSamples/RandomQuotes-Java/commit/${{ github.sha }}\", \"Comment\": \"${{ github.event.head_commit.message }}\"}],
8690
}" > dockerbuildinfo.json; cat dockerbuildinfo.json
8791
88-
- name: Push Build Info
92+
- name: Main push build Info
93+
if: github.ref == 'refs/heads/master'
8994
run: >-
9095
octo build-information
9196
"--space=${{ secrets.OCTOPUS_SERVER_SPACE }}"
@@ -95,3 +100,42 @@ jobs:
95100
--version=0.1.${{ github.run_number }}
96101
--file=dockerbuildinfo.json
97102
103+
- name: Branch build and push
104+
if: github.ref != 'refs/heads/master'
105+
id: docker_build
106+
uses: docker/build-push-action@v2
107+
with:
108+
push: true
109+
build-args: VERSION=0.1.${{ github.run_number }}-${BRANCH_NAME}
110+
tags: octopussamples/randomquotesjava:0.1.${{ github.run_number }}-${BRANCH_NAME}
111+
112+
- name: Branch build Docker build info
113+
if: github.ref != 'refs/heads/master'
114+
run: >-
115+
echo "{
116+
\"PackageId\": \"octopussamples/randomquotesjava\",
117+
\"Version\": \"0.1.${{ github.run_number }}-${BRANCH_NAME}\",
118+
\"BuildUrl\": \"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}\",
119+
\"BuildNumber\": \"${{ github.run_number }}\",
120+
\"Branch\": \"${{ github.ref }}\",
121+
\"BuildEnvironment\":\"GitHub\",
122+
\"VcsCommitNumber\":\"${{ github.sha }}\",
123+
\"VcsCommitUrl\":\"https://github.com/OctopusSamples/RandomQuotes-Java/commit/${{ github.sha }}\",
124+
\"VcsType\": \"Git\",
125+
\"VcsRoot\": \"https://github.com/OctopusSamples/RandomQuotes-Java\",
126+
\"CommentParser\": \"GitHub\",
127+
\"Commits\":
128+
[{\"Id\":\"${{ github.sha }}\", \"LinkUrl\":\"https://github.com/OctopusSamples/RandomQuotes-Java/commit/${{ github.sha }}\", \"Comment\": \"${{ github.event.head_commit.message }}\"}],
129+
}" > dockerbuildinfo.json; cat dockerbuildinfo.json
130+
131+
- name: Push Build Info
132+
if: github.ref != 'refs/heads/master'
133+
run: >-
134+
octo build-information
135+
"--space=${{ secrets.OCTOPUS_SERVER_SPACE }}"
136+
--server=${{ secrets.OCTOPUS_SERVER_URL }}
137+
--apiKey=${{ secrets.OCTOPUS_API_KEY }}
138+
--package-id=octopussamples/randomquotesjava
139+
--version=0.1.${{ github.run_number }}-${BRANCH_NAME}
140+
--file=dockerbuildinfo.json
141+

0 commit comments

Comments
 (0)