Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): Add GitHub Actions Workflow to Build and Save Docker Image as Artifact #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docker-build:
name: Build and Save Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set Image Tag
id: vars
run: |
IMAGE_TAG=$(echo "${GITHUB_REF_NAME}-${GITHUB_SHA::7}" | tr '/' '-')
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV

- name: Build Docker Image
run: docker build -t trend-finder:${{ env.IMAGE_TAG }} .

- name: Save Docker Image
run: docker save trend-finder:${{ env.IMAGE_TAG }} | gzip > trend-finder-${{ env.IMAGE_TAG }}.tar.gz

- name: Upload Docker Image Artifact
uses: actions/upload-artifact@v4
with:
name: trend-finder-image-${{ env.IMAGE_TAG }}
path: trend-finder-${{ env.IMAGE_TAG }}.tar.gz