Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit initial CI/CD pipeline #162

Merged
merged 129 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
3947c84
Initial CI/CD pipeline
Dec 27, 2021
be8eed8
Added matrix for goOS and goARCH
Dec 27, 2021
97e1a28
Merge pull request #1 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
41a68cb
Updated build
Dec 27, 2021
31aaf06
Merge pull request #2 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
49653f4
Update build cmd
Dec 27, 2021
c9bf7f2
Merge pull request #3 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
b90a460
Add branch and commit hash to CI/CD
Dec 27, 2021
422a886
Merge pull request #4 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
8a36a48
Add code to get commit sha and branch
Dec 27, 2021
32590ce
Merge pull request #5 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
523d99e
Shortened GIT branch and GIT hash code
Dec 27, 2021
29eaf95
Merge pull request #6 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
48f8f20
Add double quotes
Dec 27, 2021
2088dee
Merge pull request #7 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
649bc1b
Upadate - 1
Dec 27, 2021
135d2c4
Update build.yml
CptOfEvilMinions Dec 27, 2021
bb9699a
Upadate - 2
Dec 27, 2021
fa67cab
Merge branch 'master' into initial-cicd
CptOfEvilMinions Dec 27, 2021
c19ed8a
Merge pull request #8 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
c7b6039
Upadate - 4
Dec 27, 2021
85e9856
Merge pull request #9 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
fcc2b9e
Upadate - 5
Dec 27, 2021
d0e8ad9
Merge pull request #10 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
ad88773
Upadate - 6
Dec 27, 2021
dc5e329
Merge pull request #11 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
6146ca7
Fixed typo
Dec 27, 2021
dce1930
Upadate - 7
Dec 27, 2021
b60e03c
Merge pull request #12 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 27, 2021
cb5a404
Upadate - 8
Dec 27, 2021
ee4856d
Upadate - 9
Dec 27, 2021
30c8c4b
Upadate - 10
Dec 28, 2021
c318d5e
Merge pull request #13 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
aef9b7c
Upadate - 11
Dec 28, 2021
4d5d0b9
Merge pull request #14 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
520f2f6
Upadate - 12
Dec 28, 2021
b2f098d
Merge pull request #15 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
5208f92
Upadate - 13
Dec 28, 2021
9daaa68
Merge pull request #16 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
b4f1229
Upadate - 14
Dec 28, 2021
02000c5
Merge pull request #17 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
1c6cd4d
Upadate - 15
Dec 28, 2021
8b92dbe
Merge pull request #18 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
8f1b610
Upadate - 15
Dec 28, 2021
edc06b0
Upadate - 17
Dec 28, 2021
28dd4af
Merge pull request #19 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
4ec0daa
Upadate - 18
Dec 28, 2021
8f2516a
Upadate - 19
Dec 28, 2021
cec9f47
Merge pull request #20 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
a8c7f60
Upadate - 20
Dec 28, 2021
180ab10
Merge pull request #21 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
e3c2ece
Upadate - 21
Dec 28, 2021
e64a27f
Merge pull request #22 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
d038481
Upadate - 22
Dec 28, 2021
7769cca
Merge pull request #23 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
10d47fd
Upadate - 22
Dec 28, 2021
fc5c992
Merge pull request #24 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
8fb04f0
Upadate - 24
Dec 28, 2021
109fcaa
Merge pull request #25 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
62e76f7
Upadate - 25
Dec 28, 2021
3e302e4
Merge pull request #26 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
ac1be4a
Upadate - 26
Dec 28, 2021
9db42d4
Merge pull request #27 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
e7c1269
Upadate - 27
Dec 28, 2021
cb7c4b8
Merge pull request #28 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
7efc144
Upadate - 30
Dec 28, 2021
748d8d2
Merge pull request #29 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
340fc06
Upadate - 30
Dec 28, 2021
4e63c09
Merge pull request #30 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
d8a2d05
Upadate - 31
Dec 28, 2021
b97f2c6
Merge pull request #31 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
cce0674
Update build pipeline
Dec 28, 2021
ea03dd3
Merge pull request #32 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
a731876
Update build pipeline - 2
Dec 28, 2021
4482336
Merge pull request #33 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
5db4c93
Update build pipeline - 3
Dec 28, 2021
f331fe7
Merge pull request #34 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
ebf71ea
Update build pipeline - 4
Dec 28, 2021
878ea21
Merge pull request #35 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
39b4075
Update build pipeline - 5
Dec 28, 2021
4fd14ff
Merge pull request #36 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
8597f64
Update build pipeline - 6
Dec 28, 2021
ea7b9c5
Merge pull request #37 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
915973b
Update build pipeline - 7
Dec 28, 2021
115aa85
Merge pull request #38 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
a486d24
Update build pipeline - 8
Dec 28, 2021
463d8da
Merge pull request #39 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
3fc0650
Update build pipeline - 9
Dec 28, 2021
180adf9
Merge pull request #40 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
263ab5b
Update build pipeline - 10
Dec 28, 2021
c40ec1c
Merge pull request #41 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
d1076b2
Update build pipeline - 11
Dec 28, 2021
3bcd656
Merge pull request #42 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
910e654
Update build pipeline - 12
Dec 28, 2021
7eb2036
Merge pull request #43 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
c9b4623
Update build pipeline - 13
Dec 28, 2021
314204c
Merge pull request #44 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
1c5822c
Update build pipeline - 14
Dec 28, 2021
f8b6ee9
Merge pull request #45 from CptOfEvilMinions/initial-cicd
CptOfEvilMinions Dec 28, 2021
7a8bb4c
Update build_and_test.yml
CptOfEvilMinions Dec 28, 2021
cb67647
Update tagged-releases.yml
CptOfEvilMinions Dec 28, 2021
3228b64
Create tagged-releases.yml
CptOfEvilMinions Dec 28, 2021
d5b6d2b
Update tagged-releases.yml
CptOfEvilMinions Dec 28, 2021
a558264
Initial commit for Dockerhub
Dec 28, 2021
29c6c4a
Merge pull request #46 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
22b3fd6
Add runs-on: ubuntu-20.04
Dec 28, 2021
45e6832
Merge pull request #47 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
0e82c50
Add build args to Docker builds
Dec 28, 2021
6c2bb8b
Merge pull request #48 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
74f72b1
GHA wasn't expecting non - format
Dec 28, 2021
e894f2a
Merge pull request #49 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
91ef40f
Fix build args
Dec 28, 2021
119f80a
Merge pull request #50 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
4aa30b1
Fix build args
Dec 28, 2021
54690a9
Merge pull request #51 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
75412b3
Docker build errors -1
Dec 28, 2021
9a57a31
Merge pull request #52 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
ded88c7
Docker build errors -2
Dec 28, 2021
1f71f43
Merge pull request #53 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
ce2b94e
Added LSes
Dec 28, 2021
0a0ea10
Merge pull request #54 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
13b82a2
Added LSes -2
Dec 28, 2021
6d45875
Merge pull request #55 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
2e9c914
Rearrange downlaod and checkout
Dec 28, 2021
5e6c592
Merge pull request #56 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
0ebe428
Remove workspace build arg
Dec 28, 2021
5a6533a
Merge pull request #57 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
f470795
Docker build errors -3
Dec 28, 2021
7ece128
Merge pull request #58 from CptOfEvilMinions/cicd-docekrhub
CptOfEvilMinions Dec 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!docker/
!osctrl-tls-*.bin
!osctrl-api-*.bin
!osctrl-admin-*.bin
!osctrl-cli-*.bin
25 changes: 0 additions & 25 deletions .github/workflows/build-test.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build osctrl binaries

on:
push:
branches: [ master ]

jobs:
build_and_test:
runs-on: ubuntu-20.04
strategy:
matrix:
components: ['tls', 'admin', 'api', 'cli']
goos: ['linux']
goarch: ['amd64']
steps:
######################################## Checkout code ########################################
- name: Checkout code
uses: actions/checkout@v2

######################################## Install go to env ########################################
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.5
- run: go version

######################################## Get GO deps ########################################
- name: Get GO deps
run: go mod download

######################################## Build osctrl component ########################################
- name: Build osctrl-tls
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -o ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin \
./${{ matrix.components }}

######################################## Create ZIP of build artifacts ########################################
# https://newbedev.com/getting-current-branch-and-commit-hash-in-github-action
- name: Declare GIT hash and branch
id: vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

######################################## Upload artifacts ########################################
- name: Upload osctrl bianries
uses: actions/upload-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

- name: Create ZIP of build artifacts
uses: actions/upload-artifact@v2
id: create_zip_of_build_artifacts
with:
name: osctrl-binaries-${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }}
path: bin
114 changes: 114 additions & 0 deletions .github/workflows/tagged-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Create new osctrl release with binaries

on:
create:
tags:
- 'v*'

jobs:
build_and_test:
runs-on: ubuntu-20.04
strategy:
matrix:
components: ['tls', 'admin', 'api', 'cli']
goos: ['linux']
goarch: ['amd64']
steps:
######################################## Checkout code ########################################
- name: Checkout code
uses: actions/checkout@v2
######################################## Install go ########################################
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- run: go version
######################################## Get GO deps ########################################
- name: Get GO deps
run: go mod download
######################################## Build osctrl binaries ########################################
- name: Build osctrl-tls
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin ./${{ matrix.components }}
######################################## Upload artifacts ########################################
- name: Upload osctrl bianries
uses: actions/upload-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
path: ./bin/osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin
release:
needs: [build_and_test]
runs-on: ubuntu-20.04
strategy:
matrix:
components: ['tls', 'admin', 'api', 'cli']
goos: ['linux']
goarch: ['amd64']
steps:
######################################## Download artifacts ########################################
- name: Download osctrl bianries
uses: actions/download-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

dockerhub:
needs: [build_and_test]
runs-on: ubuntu-20.04
strategy:
matrix:
components: ['tls', 'admin', 'api', 'cli']
goos: ['linux']
goarch: ['amd64']
steps:
######################################## Create ZIP of build artifacts ########################################
# https://newbedev.com/getting-current-branch-and-commit-hash-in-github-action
- name: Declare GIT hash and branch
id: vars
shell: bash
run: |
echo ::set-output name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

######################################## checkout ########################################
- name: Checkout
uses: actions/checkout@v2

######################################## Download artifacts ########################################
- name: Download osctrl binaries
uses: actions/download-artifact@v2
with:
name: osctrl-${{ matrix.components }}-${{ matrix.goos }}-${{ matrix.goarch }}.bin

######################################## Log into Dockerhub ########################################
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

######################################## Setup Docker ########################################
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

######################################## Buld and Push Docker images ########################################
- name: Build and push
uses: docker/build-push-action@v2
id: docker_build
with:
context: .
file: ./docker/Dockerfile-osctrl-${{ matrix.components }}
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/osctrl-${{ matrix.components }}:${{ steps.vars.outputs.RELEASE_VERSION }}
build-args: |
COMPONENT=${{ matrix.components }}
GOOS=${{ matrix.goos }}
GOARCH=${{ matrix.goarch }}



3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ page-js.html

# Random notes for debug
notes.txt

# Generated bins
*.bin
Empty file added CHANGELOG.md
Empty file.
14 changes: 14 additions & 0 deletions docker/Dockerfile-osctrl-admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:20.04

ARG COMPONENT
ARG GOOS
ARG GOARCH

RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin
RUN mkdir -p /opt/osctrl/configs
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
USER osctrl-${COMPONENT}
WORKDIR /opt/osctrl
EXPOSE 9001/tcp
CMD ["/opt/osctrl/bin/osctrl-admin"]
14 changes: 14 additions & 0 deletions docker/Dockerfile-osctrl-api
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:20.04

ARG COMPONENT
ARG GOOS
ARG GOARCH

RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin
RUN mkdir -p /opt/osctrl/config
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
USER osctrl-${COMPONENT}
WORKDIR /opt/osctrl
EXPOSE 9002/tcp
CMD ["/opt/osctrl/bin/osctrl-api"]
12 changes: 12 additions & 0 deletions docker/Dockerfile-osctrl-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:20.04

ARG COMPONENT
ARG GOOS
ARG GOARCH

RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
USER osctrl-${COMPONENT}
WORKDIR /opt/osctrl
CMD [ "/opt/osctrl/bin/wait-cli.sh" ]
15 changes: 15 additions & 0 deletions docker/Dockerfile-osctrl-tls
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:20.04

ARG COMPONENT
ARG GOOS
ARG GOARCH

RUN useradd -ms /usr/sbin/nologin osctrl-${COMPONENT}
RUN mkdir -p /opt/osctrl/bin
RUN mkdir -p /opt/osctrl/scripts
RUN mkdir -p /opt/osctrl/config
COPY osctrl-${COMPONENT}-${GOOS}-${GOARCH}.bin /opt/osctrl/bin/osctrl-${COMPONENT}
USER osctrl-${COMPONENT}
WORKDIR /opt/osctrl
EXPOSE 9000/tcp
CMD ["/opt/osctrl/bin/osctrl-tls"]