-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from frankkoornstra/ci/releasing
Automate releases
- Loading branch information
Showing
7 changed files
with
119 additions
and
21 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 |
---|---|---|
|
@@ -10,7 +10,16 @@ jobs: | |
runs-on: ubuntu-18.04 | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Get milestone title | ||
id: title | ||
run: | | ||
cat $GITHUB_EVENT_PATH | jq -r .milestone.title >> $MILESTONE_TITLE_FILE | ||
echo "::set-output name=title::$(cat $MILESTONE_TITLE_FILE)" | ||
- name: Ensure tag is already present | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ steps.title.outputs.title }} | ||
|
||
- name: Create Release Notes | ||
uses: docker://decathlon/release-notes-generator-action:2.0.1 | ||
|
@@ -26,19 +35,7 @@ jobs: | |
notes="${notes//$'\r'/'%0D'}" | ||
echo ::set-output name=notes::$notes | ||
- name: Get milestone title | ||
id: title | ||
run: | | ||
cat $GITHUB_EVENT_PATH | jq -r .milestone.title >> $MILESTONE_TITLE_FILE | ||
echo "::set-output name=title::$(cat $MILESTONE_TITLE_FILE)" | ||
- name: Tag version | ||
uses: anothrNick/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CUSTOM_TAG: ${{ steps.title.outputs.title }} | ||
|
||
- name: Create Release | ||
- name: Create draft release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
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,28 @@ | ||
name: Tag Docker image version | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
env: | ||
MILESTONE_TITLE_FILE: milestone-title.txt | ||
MILESTONE_RELEASE_NOTES_FILE: release_file.md | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
DOCKER_SOURCE_IMAGE: docker.pkg.github.com/${{ github.repository }}/build:${{ github.sha }} | ||
DOCKER_TARGET_IMAGE_BASE: docker.pkg.github.com/${{ github.repository }}/elasticsearch-gist-operator | ||
jobs: | ||
tag-and-push: | ||
runs-on: ubuntu-18.04 | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Tag and push Docker image with version | ||
run: | | ||
export VERSION=$(echo ${GITHUB_REF//v} | cut -d / -f 3) | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker.pkg.github.com | ||
docker pull $DOCKER_SOURCE_IMAGE | ||
docker tag $DOCKER_SOURCE_IMAGE $DOCKER_TARGET_IMAGE_BASE:latest | ||
docker push $DOCKER_TARGET_IMAGE_BASE:latest | ||
docker tag $DOCKER_SOURCE_IMAGE $DOCKER_TARGET_IMAGE_BASE:${VERSION%.*.*} | ||
docker push $DOCKER_TARGET_IMAGE_BASE:${VERSION%.*.*} | ||
docker tag $DOCKER_SOURCE_IMAGE $DOCKER_TARGET_IMAGE_BASE:${VERSION%.*} | ||
docker push $DOCKER_TARGET_IMAGE_BASE:${VERSION%.*} |
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
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
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,23 @@ | ||
# set all to phony | ||
SHELL=bash | ||
|
||
.PHONY: * | ||
|
||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
current_dir := $(abspath $(patsubst %/,%,$(dir $(mkfile_path)))) | ||
|
||
install: upsert-github-credentials-secret update-crds deploy | ||
|
||
upsert-github-credentials-secret: # Creates a secret inside Kubernetes to be able to pull the operator image | ||
kubectl get secret github-docker-secret > /dev/null || $(MAKE) create-github-credentials-secret | ||
|
||
GITHUB_USERNAME?=$(error GITHUB_USERNAME variable must be set) | ||
GITHUB_TOKEN?=$(error GITHUB_TOKEN variable must be set. The token must have read:packages capabilities) | ||
create-github-credentials-secret: #--namespace=kube-system | ||
@kubectl create secret docker-registry github-docker-secret --docker-server=docker.pkg.github.com --docker-username=${GITHUB_USERNAME} --docker-password=${GITHUB_TOKEN} | ||
|
||
update-crds: # Updates the Custom Resource Definitions of the operator | ||
for f in ${current_dir}/crd/crd-*.yaml; do kubectl apply -f $${f}; done | ||
|
||
deploy: # Deploys the operator | ||
kubectl apply -f ${current_dir}/deployment.yaml |
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 @@ | ||
../crd |
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,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: elasticsearch-gist-operator-app | ||
labels: | ||
app: elasticsearch-gist-operator | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: elasticsearch-gist-operator | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: elasticsearch-gist-operator | ||
spec: | ||
imagePullSecrets: | ||
- name: github-docker-secret | ||
containers: | ||
- name: operator | ||
image: docker.pkg.github.com/frankkoornstra/elasticsearch-gist-operator/elasticsearch-gist-operator:latest # Using a version tag is recommended for production use | ||
imagePullPolicy: Always |