Skip to content

Commit 78e7c34

Browse files
committed
Testing new workflow
1 parent 695b066 commit 78e7c34

File tree

1 file changed

+154
-85
lines changed

1 file changed

+154
-85
lines changed

.github/workflows/maven.yml

Lines changed: 154 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,158 @@
1-
jobs:
2-
build:
3-
runs-on: ubuntu-latest
4-
steps:
5-
- uses: actions/checkout@v1
6-
with:
7-
fetch-depth: '0'
8-
- name: Install GitVersion
9-
uses: gittools/actions/gitversion/setup@v0.9.7
10-
with:
11-
versionSpec: 5.x
12-
- id: determine_version
13-
name: Determine Version
14-
uses: gittools/actions/gitversion/execute@v0.9.7
15-
with:
16-
additionalArguments: /overrideconfig mode=Mainline
17-
- name: Install Octopus Deploy CLI
18-
uses: OctopusDeploy/install-octopus-cli-action@v1
19-
with:
20-
version: latest
21-
- name: Set up JDK 1.17
22-
uses: actions/setup-java@v2
23-
with:
24-
java-version: '17'
25-
distribution: adopt
26-
- name: Set Version
27-
run: ./mvnw --batch-mode versions:set -DnewVersion=${{ steps.determine_version.outputs.semVer }}
28-
shell: bash
29-
- name: Test
30-
run: ./mvnw --batch-mode test
31-
shell: bash
32-
- if: always()
33-
name: Report
34-
uses: dorny/test-reporter@v1
35-
with:
36-
name: Maven Tests
37-
path: target/surefire-reports/*.xml
38-
reporter: java-junit
39-
fail-on-error: 'false'
40-
- name: Package
41-
run: ./mvnw --batch-mode -DskipTests=true package
42-
shell: bash
43-
- id: get_artifact
44-
name: Get Artifact Path
45-
run: |-
46-
# Find the largest WAR or JAR, and assume that was what we intended to build.
47-
echo "::set-output name=artifact::$(find target -type f \( -iname \*.jar -o -iname \*.war \) -printf "%p\n" | sort -n | head -1)"
48-
shell: bash
49-
- id: get_artifact_name
50-
name: Get Artifact Name
51-
run: |-
52-
# Get the filename without a path
53-
path="${{ steps.get_artifact.outputs.artifact }}"
54-
echo "::set-output name=artifact::${path##*/}"
55-
shell: bash
56-
- id: get_octopus_artifact
57-
name: Create Octopus Artifact
58-
run: |-
59-
# Octopus expects artifacts to have a specific file format
60-
file="${{ steps.get_artifact.outputs.artifact }}"
61-
extension="${file##*.}"
62-
octofile="randomquotes.${{ steps.determine_version.outputs.semVer }}.${extension}"
63-
cp ${file} ${octofile}
64-
echo "::set-output name=artifact::${octofile}"
65-
# The version used when creating a release is the package id, colon, and version
66-
octoversion="randomquotes:${{ steps.determine_version.outputs.semVer }}"
67-
echo "::set-output name=octoversion::${octoversion}"
68-
ls -la
69-
shell: bash
70-
- name: Push packages to Octopus Deploy 🐙
71-
uses: OctopusDeploy/push-package-action@v2
72-
env:
73-
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_API_TOKEN }}
74-
OCTOPUS_HOST: ${{ secrets.OCTOPUS_SERVER_URL }}
75-
with:
76-
overwrite_mode: OverwriteExisting
77-
packages: ${{ steps.get_octopus_artifact.outputs.artifact }}
78-
- name: Create Octopus Release
79-
uses: OctopusDeploy/create-release-action@v1.1.1
80-
with:
81-
api_key: ${{ secrets.OCTOPUS_API_TOKEN }}
82-
project: Random Quotes
83-
server: ${{ secrets.OCTOPUS_SERVER_URL }}
84-
deploy_to: Dev
85-
packages: ${{ steps.get_octopus_artifact.outputs.octoversion }}
1+
# For a detailed breakdown of this workflow, see https://octopus.com/docs/guides/deploy-java-app/to-tomcat/using-octopus-onprem-github-builtin
2+
#
3+
# The following workflow provides an opinionated template you can customize for your own needs.
4+
#
5+
# If you are not an Octopus user, the "Push to Octopus", "Generate Octopus Deploy build information",
6+
# and "Create Octopus Release" steps can be safely deleted.
7+
#
8+
# To configure Octopus, set the OCTOPUS_API_TOKEN secret to the Octopus API key, and
9+
# set the OCTOPUS_SERVER_URL secret to the Octopus URL.
10+
#
11+
# Double check the "project" and "deploy_to" properties in the "Create Octopus Release" step
12+
# match your Octopus projects and environments.
13+
#
14+
# Get a trial Octopus instance from https://octopus.com/start
15+
8616
name: Java Maven Build
8717
'on':
8818
workflow_dispatch: {}
8919
push: {}
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
fetch-depth: '0'
27+
- name: Install GitVersion
28+
uses: gittools/actions/gitversion/setup@v0.9.15
29+
with:
30+
versionSpec: 5.x
31+
- id: determine_version
32+
name: Determine Version
33+
uses: gittools/actions/gitversion/execute@v0.9.15
34+
with:
35+
additionalArguments: /overrideconfig mode=Mainline
36+
- name: Install Octopus Deploy CLI
37+
uses: OctopusDeploy/install-octopus-cli-action@v1
38+
with:
39+
version: latest
40+
- name: Set up JDK 1.17
41+
uses: actions/setup-java@v2
42+
with:
43+
java-version: '17'
44+
distribution: adopt
45+
- name: Set Version
46+
run: ./mvnw --batch-mode versions:set -DnewVersion=${{ steps.determine_version.outputs.semVer }}
47+
shell: bash
48+
- name: List Dependencies
49+
run: ./mvnw --batch-mode dependency:tree --no-transfer-progress > dependencies.txt
50+
shell: bash
51+
- name: Collect Dependencies
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: Dependencies
55+
path: dependencies.txt
56+
- name: List Dependency Updates
57+
run: ./mvnw --batch-mode versions:display-dependency-updates > dependencyUpdates.txt
58+
shell: bash
59+
- name: Collect Dependency Updates
60+
uses: actions/upload-artifact@v2
61+
with:
62+
name: Dependencies Updates
63+
path: dependencyUpdates.txt
64+
- name: Test
65+
run: ./mvnw --batch-mode test
66+
shell: bash
67+
- if: always()
68+
name: Report
69+
uses: dorny/test-reporter@v1
70+
with:
71+
name: Maven Tests
72+
path: target/surefire-reports/*.xml
73+
reporter: java-junit
74+
fail-on-error: 'false'
75+
- name: Package
76+
run: ./mvnw --batch-mode -DskipTests=true package
77+
shell: bash
78+
- id: get_artifact
79+
name: Get Artifact Path
80+
run: |-
81+
# Find the largest WAR or JAR, and assume that was what we intended to build.
82+
echo "::set-output name=artifact::$(find target -type f \( -iname \*.jar -o -iname \*.war \) -printf "%p\n" | sort -n | head -1)"
83+
shell: bash
84+
- id: get_artifact_name
85+
name: Get Artifact Name
86+
run: |-
87+
# Get the filename without a path
88+
path="${{ steps.get_artifact.outputs.artifact }}"
89+
echo "::set-output name=artifact::${path##*/}"
90+
shell: bash
91+
- name: Tag Release
92+
uses: mathieudutour/github-tag-action@v6.1
93+
with:
94+
custom_tag: ${{ steps.determine_version.outputs.semVer }}
95+
github_token: ${{ secrets.GITHUB_TOKEN }}
96+
- id: create_release
97+
name: Create Release
98+
uses: actions/create-release@v1
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
with:
102+
tag_name: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }}
103+
release_name: Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }}
104+
draft: 'false'
105+
prerelease: 'false'
106+
- name: Upload Release Asset
107+
uses: actions/upload-release-asset@v1
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
upload_url: ${{ steps.create_release.outputs.upload_url }}
112+
asset_path: ${{ steps.get_artifact.outputs.artifact }}
113+
asset_name: ${{ steps.get_artifact_name.outputs.artifact }}
114+
asset_content_type: application/octet-stream
115+
- id: get_octopus_artifact
116+
name: Create Octopus Artifact
117+
run: |-
118+
# Octopus expects artifacts to have a specific file format
119+
file="${{ steps.get_artifact.outputs.artifact }}"
120+
extension="${file##*.}"
121+
octofile="SampleMavenProject-SpringBoot.${{ steps.determine_version.outputs.semVer }}.${extension}"
122+
cp ${file} ${octofile}
123+
echo "::set-output name=artifact::${octofile}"
124+
# The version used when creating a release is the package id, colon, and version
125+
octoversion="SampleMavenProject-SpringBoot:${{ steps.determine_version.outputs.semVer }}"
126+
echo "::set-output name=octoversion::${octoversion}"
127+
ls -la
128+
shell: bash
129+
- name: Push packages to Octopus Deploy
130+
uses: OctopusDeploy/push-package-action@v2
131+
env:
132+
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_API_TOKEN }}
133+
OCTOPUS_CLI_SERVER: ${{ secrets.OCTOPUS_SERVER_URL }}
134+
with:
135+
packages: ${{ steps.get_octopus_artifact.outputs.artifact }}
136+
overwrite_mode: OverwriteExisting
137+
- name: Generate Octopus Deploy build information
138+
uses: OctopusDeploy/push-build-information-action@v3
139+
env:
140+
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_API_TOKEN }}
141+
OCTOPUS_URL: ${{ secrets.OCTOPUS_SERVER_URL }}
142+
OCTOPUS_SPACE: ${{ secrets.OCTOPUS_SPACE }}
143+
with:
144+
version: ${{ steps.determine_version.outputs.semVer }}
145+
packages: SampleMavenProject-SpringBoot
146+
overwrite_mode: OverwriteExisting
147+
- name: Create Octopus Release
148+
uses: OctopusDeploy/create-release-action@v1
149+
with:
150+
api_key: ${{ secrets.OCTOPUS_API_TOKEN }}
151+
project: SampleMavenProject-SpringBoot
152+
server: ${{ secrets.OCTOPUS_SERVER_URL }}
153+
deploy_to: Development
154+
packages: ${{ steps.get_octopus_artifact.outputs.octoversion }}
155+
permissions:
156+
id-token: write
157+
checks: write
158+
contents: write

0 commit comments

Comments
 (0)