Skip to content

Commit

Permalink
added docker action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgul committed Mar 22, 2021
1 parent 94053be commit bbabf77
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
create:
tags:
- '*'
push:
branches:
- master

env:
IMAGE_NAME: rancher-redeploy

jobs:
build:
name: Publish Docker
runs-on: ubuntu-latest

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

- name: Build Image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Push Image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ $ docker run --rm -it \
-e RANCHER_PROJECT_ID="p-sk738f" \
-e RANCHER_URL="https://rancher.example.com" \
-e RANCHER_WORKLOADS="my-workload" \
-e IMAGE_TAG="v1.2.0"
morgul/rancher-redeploy:latest
-e IMAGE_TAG="v1.2.0" \
SkewedAspect/rancher-redeploy:latest
```

(Remember when copying this that `IMAGE_TAG` is optional, and you may not want to include it.)
Expand All @@ -74,7 +74,7 @@ $ docker run --rm -it \

```yaml
- name: Update rancher deployment
uses: morgul/rancher-redeploy@latest
uses: SkewedAspect/rancher-redeploy@latest
env:
RANCHER_BEARER_TOKEN: ${{ secrets.RANCHER_BEARER_TOKEN }}
RANCHER_CLUSTER_ID: 'c-kwbgu'
Expand Down Expand Up @@ -115,7 +115,7 @@ build docker:
deploy docker:
stage: deploy
image: morgul/rancher-deploy:latest
image: SkewedAspect/rancher-deploy:latest
only:
- /^v\d+\.\d+\.\d+.*/
except:
Expand Down

0 comments on commit bbabf77

Please sign in to comment.