Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit fddebe7

Browse files
authored
Merge pull request #245 from upanasiuk/docker_build_image
Github workflows build docker image
2 parents 687f82a + 961bcf0 commit fddebe7

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
16+
jobs:
17+
build_and_push:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Login to GHCR
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build Docker image
37+
uses: docker/build-push-action@v6
38+
with:
39+
context: .
40+
load: true
41+
platforms: linux/amd64
42+
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/tapswapbot:latest
43+
44+
- name: Create .env file
45+
run: |
46+
echo "API_ID=12345" > .env
47+
echo "API_HASH=12345" >> .env
48+
49+
- name: Run container
50+
run: |
51+
docker compose up -d
52+
docker compose ps
53+
54+
- name: Check container status
55+
run: |
56+
container_status=$(docker compose ps --status running --format "table {{.Name}}\t{{.Image}}\t{{.Command}}\t{{.Service}}\t{{.CreatedAt}}\t{{.Status}}\t{{.Ports}}")
57+
echo "$container_status"
58+
if echo "$container_status" | grep -q "Up"; then
59+
echo "Container is running. Proceeding."
60+
else
61+
echo "Container is not running. Exiting."
62+
exit 1
63+
fi
64+
65+
- name: Push Docker image
66+
if: success()
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
push: true
71+
platforms: linux/amd64
72+
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/tapswapbot:latest

0 commit comments

Comments
 (0)