Skip to content

Commit

Permalink
Create buildandpush.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
anishbista60 committed Sep 3, 2024
1 parent 707af76 commit c3521d3
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/buildandpush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Publish with ko

on:
push:
paths:
- 'Production-Ready-project/**'
branches: ['main']

jobs:
release-ko:
name: Release with ko
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.5'

- name: Set up ko
uses: ko-build/[email protected]
with:
version: v0.14.1 # Specify the version of ko if needed

- name: Log in to Docker Hub
env:
KO_DOCKER_REPO: docker.io/anish60 # Update with your Docker Hub namespace
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | ko login docker.io --username ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Get git SHA short
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and Publish with ko
env:
KO_DATA_PATH: kodata/
KO_DOCKER_REPO: docker.io/anish60
run: |
ko build -t sha-${{ env.sha_short }}
- name: Generate deploy manifest from Jinja template
uses: cuchi/[email protected]
with:
template: tmpl/deploy.j2
output_file: deploy/deploy.yaml
strict: true
variables: |
image_deploy_tag=sha-${{ env.sha_short }}
- name: Configure git for the action
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Stash unstaged changes
run: git stash --include-untracked

- name: Pull latest changes from the remote branch
run: git pull origin main --rebase

- name: Apply stashed changes
run: git stash pop || echo "No stashed changes to apply"

- name: Commit deploy manifest on local repo
run: |
git add deploy/deploy.yaml
git commit -s -m "[skip ci] Generate deployment manifests"
- name: Push deploy manifests to remote repo
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main

2 changes: 1 addition & 1 deletion Production-Ready-project/kodata/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Kubesimplify DevOps Project Completed!</title>
<title>DevOps Project Completed!</title>
<style>
body {
font-family: 'Arial', sans-serif;
Expand Down

0 comments on commit c3521d3

Please sign in to comment.