forked from GoogleCloudPlatform/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (106 loc) · 3.99 KB
/
paymentservice-docker.yaml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# This workflow builds and pushes images to the octopussamples DockerHub organization.
name: Payment Service Docker Build
'on':
workflow_dispatch: {}
push:
paths:
- 'src/paymentservice/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install Octopus Deploy CLI
uses: OctopusDeploy/install-octopus-cli-action@v1
with:
version: latest
- id: fixed_branch_name
name: Create branch name
run: |
BRANCH_NAME=${{ github.event.ref }}
BRANCH_NAME=${BRANCH_NAME#refs/heads/}
FIXED_BRANCH_NAME=${BRANCH_NAME//[^a-zA-Z0-9-]/-}
echo "fixedbranch=$FIXED_BRANCH_NAME" >> $GITHUB_ENV
shell: bash
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_SAMPLES_USERNAME }}
password: ${{ secrets.DOCKERHUB_SAMPLES_PASSWORD }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- id: determine_version
name: Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: /overrideconfig mode=Mainline
- name: Build and push
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:src/paymentservice"
push: true
tags: octopussamples/paymentservice:${{ steps.determine_version.outputs.semVer }}
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install Cyclone DX
run: npm install --global @cyclonedx/cyclonedx-npm
- name: Install Dependencies
run: npm install
working-directory: src/paymentservice
- name: Build SBOM
run: cyclonedx-npm --output-file bom.xml
working-directory: src/paymentservice
- name: Build SBOM package
run: >
octo pack
--id paymentservice-sbom
--version ${{ steps.determine_version.outputs.semVer }}
--format zip
--include **/bom.xml
shell: bash
working-directory: src/paymentservice
- name: Publish SBOM file
run: >
mvn deploy:deploy-file
--batch-mode
-Dfile=paymentservice-sbom.${{ steps.determine_version.outputs.semVer }}.zip
-Durl="https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@maven.pkg.github.com/${{ github.repository }}"
-DgroupId=microservices-demo
-DartifactId=paymentservice-sbom
-Dversion=${{ steps.determine_version.outputs.semVer }}
-Dpackaging=zip;
exit 0
shell: "bash -l {0}" # Allow commands to fail by removing the default "-e" argument
working-directory: src/paymentservice
- name: Create Mainline Octopus Release
if: github.ref == 'refs/heads/main'
uses: OctopusDeploy/create-release-action@v1
with:
api_key: ${{ secrets.OCTOPUS_APIKEY }}
space: ${{ secrets.OCTOPUS_SPACE }}
project: Payment Service
channel: Mainline
server: ${{ secrets.OCTOPUS_SERVER }}
deploy_to: Development
package_version: ${{ steps.determine_version.outputs.semVer }}
# Only the frontend project has feature branches set up
# - name: Create Branch Octopus Release
# if: github.ref != 'refs/heads/main'
# uses: OctopusDeploy/create-release-action@v1
# with:
# api_key: ${{ secrets.OCTOPUS_APIKEY }}
# space: ${{ secrets.OCTOPUS_SPACE }}
# project: Payment Service
# channel: ${{ env.fixedbranch }}
# server: ${{ secrets.OCTOPUS_SERVER }}
# deploy_to: ${{ env.fixedbranch }}
# package_version: ${{ steps.determine_version.outputs.semVer }}