-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (53 loc) · 1.6 KB
/
Copy pathdocker-build.yml
File metadata and controls
62 lines (53 loc) · 1.6 KB
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
name: DOCKER-BUILD-CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# CHECK IF DOCKERFILE EXIST...
check_dockerfile:
runs-on: ubuntu-latest
outputs:
skip_ci: ${{ steps.check.outputs.skip_ci }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for Dockerfile
id: check
run: |
if [ ! -f "${{ github.workspace }}/Dockerfile" ]; then
echo "🚫 No Dockerfile found, skipping CI."
echo "skip_ci=true" >> $GITHUB_OUTPUT
else
echo "skip_ci=false" >> $GITHUB_OUTPUT
fi
# IF DOCKERFILE EXIST: BUILD
build:
needs: check_dockerfile
if: needs.check_dockerfile.outputs.skip_ci == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl bash
source .env && task --version
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Run Task to build and push Docker image
run: |
source .env
export TASK_X_REMOTE_TASKFILES=1
task --download -y
task docker:ci:build_push \
SRC_DIR="${{ github.workspace }}" \
REGISTRY="ghcr.io" \
REPOSITORY="$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" \
SRC="${{ github.workspace }}"