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

improve CI/CD #12

Merged
merged 49 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
094472a
fix
jodevsa Mar 15, 2022
73e4cd1
test
jodevsa Mar 15, 2022
9915897
test
jodevsa Mar 15, 2022
b109d50
fix
jodevsa Mar 15, 2022
f7cbde0
test
jodevsa Mar 15, 2022
216137b
print steps
jodevsa Mar 15, 2022
0893874
new_branch
jodevsa Mar 16, 2022
48281c1
change
jodevsa Mar 19, 2022
e886e56
fix
jodevsa Mar 19, 2022
be641d4
fix
jodevsa Mar 19, 2022
c3a8e0a
fixes
jodevsa Mar 19, 2022
adb183d
fix
jodevsa Mar 19, 2022
000db7b
test
jodevsa Mar 19, 2022
710329a
test
jodevsa Mar 19, 2022
c757ba2
fix
jodevsa Mar 19, 2022
837bdd9
test
jodevsa Mar 19, 2022
40c2e09
test
jodevsa Mar 19, 2022
6112046
fix
jodevsa Mar 19, 2022
443506f
fix
jodevsa Mar 19, 2022
55fdbc5
change
jodevsa Mar 19, 2022
82224b6
push
jodevsa Mar 19, 2022
702019f
fix
jodevsa Mar 19, 2022
c8967a5
test
jodevsa Mar 19, 2022
d1daf35
fix
jodevsa Mar 19, 2022
cb9ee24
fix
jodevsa Mar 19, 2022
dfbd1d9
test
jodevsa Mar 19, 2022
0df0959
Merge dfbd1d9c40d60c433c1d842545d39c7450ba3fb7 into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
6eaab57
new release
jodevsa Mar 19, 2022
c7986f6
fix
jodevsa Mar 19, 2022
ea3f383
Merge c7986f68d03cefe855fbf74c7f976a81d33eb128 into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
21612bf
new release
jodevsa Mar 19, 2022
b054300
fix
jodevsa Mar 19, 2022
be15091
fix
jodevsa Mar 19, 2022
f423c09
Merge be15091ef2d2d4498050a88c058cf6c14c5842bf into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
fc14ecf
new release
jodevsa Mar 19, 2022
7c1d653
fix
jodevsa Mar 19, 2022
e4362ea
Merge 7c1d65318d1156491ce1a0e857b2fdf912505247 into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
328a019
new release
jodevsa Mar 19, 2022
9dc0261
new line
jodevsa Mar 19, 2022
e28a483
fixes
jodevsa Mar 19, 2022
71bdeaa
fixes
jodevsa Mar 19, 2022
c2b5d87
Merge 71bdeaa15df3f21d48e3d2f9d8460a7104ff4894 into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
ba5f60a
new release
jodevsa Mar 19, 2022
a58e690
fix
jodevsa Mar 19, 2022
4e28ce1
Merge a58e690f84a4cb775a229106af715362773ae5ee into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
4937fb7
new release
jodevsa Mar 19, 2022
467c3fe
fix
jodevsa Mar 19, 2022
6f04ef8
Merge 467c3fe1d21e0502203705add49cbe6a1e1913ea into 1baf9a94b657f72d1…
jodevsa Mar 19, 2022
15bbba5
new release
jodevsa Mar 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/build-publish-operator-bundle.yaml

This file was deleted.

97 changes: 92 additions & 5 deletions .github/workflows/build-publish-operator-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,38 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-operator
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Test
run: make test

build-and-push-operator-image:
runs-on: ubuntu-latest
needs: [build-and-push-wireguard-image]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: load wireguard image url
env:
WIREGUARD_IMAGE: ${{ needs.build-and-push-wireguard-image.outputs.image }}
run : |
printf "WIREGUARD_IMAGE: \"$WIREGUARD_IMAGE\"" > release-config.yaml

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
Expand All @@ -37,7 +57,10 @@ jobs:
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,format=long
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/operator

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
Expand All @@ -46,7 +69,71 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs:
image: ${{ steps.meta.outputs.tags }}

build-and-push-wireguard-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: update release config
run: echo ${{ steps.meta }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
tags: |
type=ref,event=branch
type=sha,format=long
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/wireguard

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./wireguard-image
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

outputs:
image: ${{ steps.meta.outputs.tags }}

save-release:
needs: [build-and-push-operator-image, build-and-push-wireguard-image]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: prepare new release
env:
OPERATOR_IMAGE: ${{ needs.build-and-push-operator-image.outputs.image }}
WIREGUARD_IMAGE: ${{ needs.build-and-push-wireguard-image.outputs.image }}
run : |
git config --local user.email "jodevsa@gmail.com"
git config --local user.name "Github action"
printf "WIREGUARD_IMAGE: \"$WIREGUARD_IMAGE\"\nOPERATOR_IMAGE: \"$OPERATOR_IMAGE\"" > release-config.yaml
make update-controller-image
git add release-config.yaml
git add config/manager/kustomization.yaml
git commit -m "new release" -a

- name: commit new release
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
46 changes: 0 additions & 46 deletions .github/workflows/build-push-wireguard-image.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/test-operator.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN go mod download
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY release-config.yaml release-config.yaml

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
Expand All @@ -23,6 +22,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY release-config.yaml release-config.yaml
USER 65532:65532

ENTRYPOINT ["/manager"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

update-controller-image: kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}

deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/jodevsa/wireguard-operator-operator
newTag: main
newName: ghcr.io/jodevsa/wireguard-operator/operator
newTag: sha-6f04ef8fef3e7e685084b894b4ec9926e533aab7
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ func init() {
}

func main() {
viper.SetConfigName("release-config")
viper.SetConfigType("yaml")
viper.AddConfigPath("./")
err := viper.ReadInConfig()
if err != nil {
setupLog.Error(err, "Unable to read viper config")
os.Exit(1)
}

var metricsAddr string
var enableLeaderElection bool
var probeAddr string
Expand All @@ -75,6 +66,15 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

viper.SetConfigName("release-config")
viper.SetConfigType("yaml")
viper.AddConfigPath("./")
err := viper.ReadInConfig()
if err != nil {
setupLog.Error(err, "Unable to read viper config")
os.Exit(1)
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down
4 changes: 2 additions & 2 deletions release-config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WIREGUARD_IMAGE: "ghcr.io/jodevsa/wireguard-operator-wireguard-image:main"
OPERATOR_IMAGE: "ghcr.io/jodevsa/wireguard-operator-operator:main"
WIREGUARD_IMAGE: "ghcr.io/jodevsa/wireguard-operator/wireguard:sha-6f04ef8fef3e7e685084b894b4ec9926e533aab7"
OPERATOR_IMAGE: "ghcr.io/jodevsa/wireguard-operator/operator:sha-6f04ef8fef3e7e685084b894b4ec9926e533aab7"