From eefbab12740020e13305b0b529b8d0af8c11048b Mon Sep 17 00:00:00 2001 From: Impeqq Date: Mon, 6 Jan 2025 22:01:06 +0400 Subject: [PATCH] ci: add github actions --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e91557f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: Messenger + +on: + push: + branches: + - main + - features/** + - dependabot/** + - master + pull_request: + branches: + - main + +jobs: + docker: + timeout-minutes: 10 + runs-on: ubuntu-latest + strategy: + matrix: + include: + - dockerfile: ./frontend/Dockerfile + context: ./frontend + image: ghcr.io/Impeqq/web + - dockerfile: ./backend/Dockerfile + context: ./backend + image: ghcr.io/Impeqq/api + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ matrix.image }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + context: ${{ matrix.context }} + file: ${{ matrix.dockerfile }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Run Docker Compose + run: docker compose up -d \ No newline at end of file