-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.99 KB
/
dev.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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