This repository has been archived by the owner on Nov 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:crestalnetwork/ethglobal-bangkok
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Build Backend | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: read | ||
packages: write | ||
steps: | ||
- | ||
name: Get commit message | ||
id: commit_message | ||
uses: sergeysova/jq-action@v2 | ||
with: | ||
cmd: echo -n "${{github.event.head_commit.message}}" | jq -Rsa . | sed -e 's/^"//' -e 's/"$//' | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: "backend/Dockerfile" | ||
build-args: | | ||
RELEASE=${{ github.run_number }} | ||
GH_CI_USER=${{ secrets.GH_CI_USER }} | ||
GH_CI_TOKEN=${{ secrets.GH_CI_TOKEN }} | ||
push: true | ||
tags: ghcr.io/crestalnetwork/crestalnetwork/ethglobal-bangkok:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
- | ||
name: Post to a Slack channel | ||
if: ${{ success() }} | ||
id: slack-success | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: 'C0786MHAL8J' | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "`${{ github.repository }}`\n*Branch*: `${{ github.ref_name }}`\n*Build result*: (${{ github.run_number }}) *${{ job.status }}* 🟩\n*Changes*:\n${{ steps.commit_message.outputs.value }}\n*Diff*: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | ||
- | ||
name: Post to a Slack channel | ||
if: ${{ failure() }} | ||
id: slack-failure | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: 'C0786MHAL8J' | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "`${{ github.repository }}`\n*Branch*: `${{ github.ref_name }}`\n*Build result*: (${{ github.run_number }}) *${{ job.status }}* 🟥\n*Build Log*: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Changes*:\n${{ steps.commit_message.outputs.value }}\n*Diff*: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# build | ||
FROM golang:1.23 AS build-env | ||
|
||
WORKDIR /app | ||
|
||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change | ||
COPY go.mod go.sum ./ | ||
RUN go mod download && go mod verify | ||
|
||
# no cache below this line | ||
ADD . /app | ||
|
||
RUN --mount=type=cache,target=/root/.cache/go-build go test ./... && go build -o bin/api ./backend | ||
|
||
|
||
# mini image | ||
FROM debian:12-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y -q --no-install-recommends ca-certificates curl \ | ||
&& apt-get clean | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build-env /app/bin/api /usr/bin/api | ||
|
||
ARG RELEASE | ||
|
||
ENV RELEASE=$RELEASE | ||
|
||
ENTRYPOINT ["api"] |