Merge pull request #40 from kahootali/remove-deprecated-steps #49
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: CD | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
Build-and-Deploy: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
name: Build and Push Image to Image registry | |
env: | |
REGISTRY: docker.io | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Set up Go 1.20 | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- name: Build Code | |
run: | | |
go mod download | |
go build -v . | |
- name: Generate Version | |
id: generate_version | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DRY_RUN: true | |
DEFAULT_BUMP: "patch" | |
- name: Generate Vars | |
id: generate_vars | |
run: | | |
IMAGE_TAG=${{ steps.generate_version.outputs.new_tag }} | |
# Just Image name | |
IMAGE_NAME=${{ github.repository }} | |
#Image ID= Name + Tag | |
IMAGE_ID=$IMAGE_NAME:$IMAGE_TAG | |
IMAGE_REPO=$REGISTRY/$IMAGE_ID | |
echo "Image: $IMAGE_REPO" | |
echo "image=$IMAGE_REPO" >>$GITHUB_OUTPUT | |
echo "image_name=$IMAGE_NAME" >>$GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Echo Output | |
run: | | |
echo "Image from Output: ${{ steps.generate_vars.outputs.image }}" | |
echo "Repo from Output: ${{ steps.generate_vars.outputs.image_name }}" | |
- name: Build and Push Docker Image | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./Dockerfile | |
pull: true | |
push: true | |
tags: ${{ steps.generate_vars.outputs.image }} | |
- name: Push tag | |
uses: anothrNick/[email protected] | |
id: tag_version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DEFAULT_BUMP: "patch" | |
- name: Create a GitHub release | |
id: 'github_release' | |
uses: ncipollo/[email protected] | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: ${{ steps.tag_version.outputs.new_tag }} | |
generateReleaseNotes: true | |
# - name: Deploy | |
# uses: steebchen/[email protected] | |
# with: | |
# config: ${{ secrets.KUBE_CONFIG }} | |
# command: set image -n prod deployment/golang-deployment golang=${{ env.IMAGE }} | |
- name: Notify Slack | |
uses: 8398a7/action-slack@v3 | |
if: always() | |
with: | |
status: ${{ job.status }} | |
fields: repo,author,action,eventName,ref,workflow | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} |