Skip to content

Commit

Permalink
GHA Migration (#18)
Browse files Browse the repository at this point in the history
* Migrate to GHA

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Migrate to GHA

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

---------

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
  • Loading branch information
galal-hussein committed May 20, 2024
1 parent 03a6b3f commit dc98e88
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 226 deletions.
224 changes: 0 additions & 224 deletions .drone.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
push:
branches:
- master
pull_request:

name: Build
permissions:
contents: read
jobs:
build-cross-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cross Arch Build
run: |
make ci
env:
CROSS: "true"
GH_TAG: ${{ github.ref_name }}
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
push:
tags:
- "v*"

name: Release
permissions:
contents: write
id-token: write
jobs:
release-cross-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cross Arch Build
run: |
make ci
env:
CROSS: "true"
GH_TAG: ${{ github.ref_name }}

- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;
- name: release binaries
uses: softprops/action-gh-release@v2
with:
files: |
dist/artifacts/*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Build container image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: rancher/migration-agent:${{ github.ref_name }}
file: package/Dockerfile
platforms: linux/amd64, linux/arm64, linux/arm



2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
fi

ENV GO111MODULE on
ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS
ENV DAPPER_ENV REPO TAG CROSS
ENV DAPPER_SOURCE /go/src/github.com/rancher/migration-agent/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
Expand Down
2 changes: 2 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/migration-a
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/migration-agent-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/migration-agent-windows
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/migration-agent-arm64
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/migration-agent-arm
fi
2 changes: 1 addition & 1 deletion scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
fi

COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
GIT_TAG=${GH_TAG:-$(git tag -l --contains HEAD | head -n 1)}

if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
Expand Down

0 comments on commit dc98e88

Please sign in to comment.