Skip to content

Merge pull request #62 from kennyd3d/workflow-dropdown #230

Merge pull request #62 from kennyd3d/workflow-dropdown

Merge pull request #62 from kennyd3d/workflow-dropdown #230

Workflow file for this run

# To understand how this workflow works see:
# (Diagram) https://github.com/user-attachments/assets/ab1ac4ab-09ec-4315-a33f-c2acb4a58e9d
name: Build, Test, & Deploy for Dev
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- dev
push:
branches:
- dev
env:
ARTIFACT_NAME: actions-demo
jobs:
build_test_and_deploy_dev:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Preparing job
run: |
SHA_SHORT=$(echo $GITHUB_SHA | cut -c1-7)
echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV
echo "Short SHA: $SHA_SHORT"
IMAGE_DEV="kennyd3d/${{ env.ARTIFACT_NAME }}:$SHA_SHORT"
echo "IMAGE_DEV=$IMAGE_DEV" >> $GITHUB_ENV
echo "DEV: $IMAGE_DEV"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run tests
run: |
echo "Fake running some test"
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
context: .
tags: |
${{ env.IMAGE_DEV }}
kennyd3d/${{ env.ARTIFACT_NAME }}:dev
- name: Push Docker Image if merged
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/dev' }}
run: |
docker push ${{ env.IMAGE_DEV }}
- name: Deploy to Dev
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/dev' }}
run: |
echo "Pretending to deploy to k8"
echo "## Successfully deployed ${{ env.IMAGE_DEV }} to Dev ✅" >> $GITHUB_STEP_SUMMARY
- name: Run success message on successful deployment if pushed to dev
if: ${{ github.event_name == 'push' && success() }}
run: |
echo "# 🎊 Successfully deployed ${{ env.IMAGE_DEV }} to Dev ✅" >> $GITHUB_STEP_SUMMARY