-
Notifications
You must be signed in to change notification settings - Fork 803
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
Suffix amazonlinux image with -amazonlinux and push debian image to GitHub #639
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,79 @@ | ||
name: Container Images | ||
|
||
on: push | ||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
buildx: | ||
# this is to prevent the job to run at forked projects | ||
if: github.repository == 'kubernetes-sigs/aws-ebs-csi-driver' | ||
env: | ||
IMAGE: aws-ebs-csi-driver | ||
DEB_BUILD_TAG: aws-ebs-csi-driver:debian | ||
AL2_BUILD_TAG: aws-ebs-csi-driver:amazonlinux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v3 | ||
with: | ||
buildx-version: latest | ||
qemu-version: latest | ||
- name: Build container image | ||
run: | | ||
docker buildx build \ | ||
-t aws-ebs-csi-driver \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=false" . \ | ||
--target=amazonlinux | ||
- name: Push to Github registry | ||
run: | | ||
USER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) | ||
BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3) | ||
IMAGE=aws-ebs-csi-driver | ||
if [ "$BRANCH" = "master" ]; then | ||
TAG="latest" | ||
else | ||
TAG=$BRANCH | ||
fi | ||
docker login docker.pkg.github.com -u $USER -p ${{ secrets.REGISTRY_TOKEN }} | ||
docker build -t aws-ebs-csi-driver . --target amazonlinux | ||
docker tag aws-ebs-csi-driver docker.pkg.github.com/$GITHUB_REPOSITORY/$IMAGE:$TAG | ||
docker push docker.pkg.github.com/$GITHUB_REPOSITORY/$IMAGE:$TAG | ||
- name: Push to Dockerhub registry | ||
run: | | ||
BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3) | ||
REPO=amazon/aws-ebs-csi-driver | ||
if [ "$BRANCH" = "master" ]; then | ||
TAG="latest" | ||
else | ||
TAG=$BRANCH | ||
fi | ||
docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }} | ||
docker buildx build \ | ||
-t $REPO:$TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=true" . \ | ||
--target=amazonlinux | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Build debian target | ||
run: | | ||
docker buildx build \ | ||
-t $DEB_BUILD_TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=false" . | ||
--target=debian-base | ||
- name: Build amazonlinux target | ||
run: | | ||
docker buildx build \ | ||
-t $AL2_BUILD_TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=false" . \ | ||
--target=amazonlinux | ||
- name: Set environment variables | ||
run: | | ||
BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3) | ||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV | ||
if [ "$BRANCH" = "master" ]; then | ||
TAG="latest" | ||
else | ||
TAG=$BRANCH | ||
fi | ||
echo "TAG=$TAG" >> $GITHUB_ENV | ||
- name: Login to GitHub | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.REGISTRY_TOKEN }} | ||
- name: Push debian target to GitHub | ||
run: | | ||
DEB_PUSH_TAG="docker.pkg.github.com/$GITHUB_REPOSITORY/$IMAGE:$TAG" | ||
docker buildx build \ | ||
-t $DEB_PUSH_TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=true" . \ | ||
--target=debian-base | ||
- name: Push amazonlinux target to GitHub | ||
run: | | ||
AL2_PUSH_TAG="docker.pkg.github.com/$GITHUB_REPOSITORY/$IMAGE:$TAG-amazonlinux" | ||
docker buildx build \ | ||
-t $AL2_PUSH_TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=true" . \ | ||
--target=amazonlinux | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Push amazonlinux target to Docker Hub | ||
run: | | ||
AL2_PUSH_TAG="amazon/$IMAGE:$TAG-amazonlinux" | ||
docker buildx build \ | ||
-t $AL2_PUSH_TAG \ | ||
--platform=linux/arm64,linux/amd64 \ | ||
--output="type=image,push=true" . \ | ||
--target=amazonlinux |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this uses the cache from previous build step ($DEB_BUILD_TAG) . If not, there is no point to $DEB_BUILD_TAG/ $AL2_BUILD_TAG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm a little bit confused. What's the benefit of build steps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes it quicker to debug what failed. if build succeed but push step failed. etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from local testing the build step image is cached so IMO it makes sense to separate the two steps