-
Notifications
You must be signed in to change notification settings - Fork 767
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github workflow to build and publish container image
It publishes to both dockerhub and github registry
- Loading branch information
Cheng Pan
committed
Oct 3, 2019
1 parent
6b5170f
commit 7565fd8
Showing
1 changed file
with
38 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Container Images | ||
|
||
on: push | ||
jobs: | ||
build: | ||
# this is to prevent the job to run at forked projects | ||
if: github.repository == 'kubernetes-sigs/aws-ebs-csi-driver' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Build container image | ||
run: | | ||
docker build -t aws-ebs-csi-driver . | ||
- 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 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) | ||
IMAGE=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 tag aws-ebs-csi-driver ${{secrets.DOCKERHUB_USER}}/$IMAGE:$TAG | ||
docker push ${{secrets.DOCKERHUB_USER}}/$IMAGE:$TAG |