Skip to content

Commit

Permalink
Merge pull request #91 from rancher/chore/port-gha-migration
Browse files Browse the repository at this point in the history
[GHA MIGRATION] Porting changes to release/v2.7
  • Loading branch information
guangyee authored Jun 12, 2024
2 parents d3fcaac + d45e9e8 commit 3156c35
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 208 deletions.
207 changes: 0 additions & 207 deletions .drone.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build
on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Run Dapper CI
run: make ci
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Release
on:
push:
tags: 'v*'

# Needed to create the release
permissions:
contents: write
id-token: write

# Needed to create the release and use gh cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Create a Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
prerelease: true

build-and-push-amd64:
runs-on: ubuntu-latest
needs: [create-release]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Run Dapper CI
run: make ci
- name: Generate Checksum
run: |
cd dist/artifacts
sha256sum * > sha256sum-amd64.txt
- name: Upload Assets
run: |
ASSETS_DIR="dist/artifacts"
TAG=${{ github.ref_name }}
for file in $ASSETS_DIR/*; do
gh release upload $TAG $file --repo ${{ github.repository }}
done
- name: Build Manifest
id: metadata
uses: docker/metadata-action@v5
with:
images: |
docker.io/rancher/rancher-csp-adapter
709825985650.dkr.ecr.us-east-1.amazonaws.com/suse/rancher/rancher-csp-adapter
flavor: |
latest=false
- name: Read Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr/credentials accessKeyId | ECR_ACCESS_KEY ;
secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr/credentials secretAccessKey | ECR_SECRET_KEY ;
secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr-eu/credentials accessKeyId | ECR_ACCESS_KEY_EU ;
secret/data/github/repo/${{ github.repository }}/aws/aws-rancher-csp-adapter-ecr-eu/credentials secretAccessKey | ECR_SECRET_KEY_EU ;
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.ECR_ACCESS_KEY }}
aws-secret-access-key: ${{ env.ECR_SECRET_KEY }}
aws-region: us-east-1
- name: Login to ECR
uses: docker/login-action@v2
with:
registry: 709825985650.dkr.ecr.us-east-1.amazonaws.com
- name: Push Images to Registries
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
file: package/Dockerfile
platforms: linux/amd64
- name: Build Manifest for EU Registry Images
id: metadata_eu
uses: docker/metadata-action@v5
with:
images: |
709825985650.dkr.ecr.us-east-1.amazonaws.com/suse/rancher/rancher-csp-adapter-eu
flavor: |
latest=false
- name: Configure AWS credentials for EU Registry
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.ECR_ACCESS_KEY_EU }}
aws-secret-access-key: ${{ env.ECR_SECRET_KEY_EU }}
aws-region: us-east-1
- name: Login to ECR for EU Registry
uses: docker/login-action@v2
with:
registry: 709825985650.dkr.ecr.us-east-1.amazonaws.com
- name: Push Images to EU Registry
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.metadata_eu.outputs.tags }}
labels: ${{ steps.metadata_eu.outputs.labels }}
file: package/Dockerfile
platforms: linux/amd64
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH

RUN zypper -n up && \
zypper -n in git docker vim less file curl wget ca-certificates
zypper -n in git docker vim less file curl wget ca-certificates gawk
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2; \
fi
Expand Down

0 comments on commit 3156c35

Please sign in to comment.