Merge branch 'release/v1.0.33' #7
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
name: Build and Release KDT | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
push_to_registry: | |
name: Build and Publish KDT | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: 'kondukto/kondukto-cli' | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Add SHORT_SHA env property | |
id: set_short_sha_variable | |
run: | | |
echo "SHORT_SHA=`git rev-parse --short HEAD`" >> $GITHUB_ENV | |
- name: Get Last Tag | |
run: | | |
git fetch --prune --unshallow --tags | |
echo GIT_TAG=$(git describe --tags --abbrev=0) >> $GITHUB_ENV | |
- name: Get Version Tag | |
id: get_version_tag | |
run: | | |
echo "VERSION_TAG=${{ env.GIT_TAG }}" | cut -d '-' -f 1 >> $GITHUB_ENV | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22.x | |
cache: true | |
cache-dependency-path: ./go.sum | |
- name: Build and Show Version | |
id: build_and_show_version | |
run: | | |
make test | |
make test_coverage | |
make go.mod | |
make vet | |
make all | |
_release/kdt-linux-amd64 version | |
- name: Create Release | |
uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION_TAG }} | |
release_name: Release ${{ env.VERSION_TAG }} | |
prerelease: false | |
draft: true | |
body: | | |
Changes in release | |
- this | |
- name: Upload Release Assets | |
id: upload-release-assets | |
uses: dwenegar/upload-release-assets@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_id: ${{ steps.create_release.outputs.id }} | |
assets_path: ./_release/ | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build/Push Tags | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: | | |
${{ env.IMAGE_NAME }}:latest | |
${{ env.IMAGE_NAME }}:${{ env.VERSION_TAG }} | |
${{ env.IMAGE_NAME }}:${{ env.VERSION_TAG }}-${{ env.SHORT_SHA }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-central-1 | |
- name: Deploy to S3 | |
run: | | |
aws s3 cp ./get.sh s3://${{ secrets.AWS_S3_BUCKET_ID }}/index.html | |
- name: Invalidate CDN | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |