diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 026cd3e..dba744a 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -1,6 +1,9 @@ name: Sample Testing on: [push] +env: + VER: 0.1.2 + jobs: my_job: runs-on: stackit-docker @@ -8,7 +11,7 @@ jobs: steps: - name: First Chat Message if: ${{ always() }} - uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v0.1.2 + uses: https://stackit-solutions.git.onstackit.cloud/actions/notify@v${{ env.VER }} with: title: "[START] sample test (${{ forgejo.run_number }})" author: ${{ forgejo.actor }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a9f9d33 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: CI +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +# If a 403 error occurs, make sure to set content permission to write +# see: https://github.com/go-semantic-release/action/issues/27 +permissions: + contents: write + +jobs: + lint: + runs-on: stackit-docker + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.26 + - uses: golangci/golangci-lint-action@v3 + +# build: +# runs-on: stackit-docker +## strategy: +## fail-fast: true +## matrix: +## node: [10, 12] +# steps: +# - uses: actions/checkout@v6 +# +# - uses: actions/setup-node@v1 +# with: +# node-version: ${{ matrix.node }} +# - run: npm ci +# - run: npm test + release: + runs-on: stackit-docker +# needs: build + steps: + - uses: actions/checkout@v6 + + - uses: go-semantic-release/action@v1 + id: semrel + with: + github-token: ${{ env.FORGEJO_TOKEN }} + allow-initial-development-versions: true + # update-file: package.json + changelog-file: CHANGELOG.md + changelog-generator-opt: "emojis=true" + + - + name: Login to Docker Hub + if: steps.semrel.outputs.version != '' + uses: docker/login-action@v4 + with: + registry: ${{ forgejo.server_url }} + username: ${{ vars.GIT_USERNAME }} + password: ${{ secrets.GIT_PAT }} + +# - name: Set up QEMU +# if: steps.semrel.outputs.version != '' +# uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + if: steps.semrel.outputs.version != '' + uses: docker/setup-buildx-action@v4 + + - name: Build and push + uses: docker/build-push-action@v7 + with: + push: false + tags: actions/notify-slim:${{ steps.semrel.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 20cd801..f3035dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,29 @@ -FROM golang:1.26 +FROM golang:1.26 AS builder -WORKDIR /src +RUN apt-get update && apt-get -y install upx + +WORKDIR /app + +ENV CGO_ENABLED=0 COPY . . -RUN go get -u github.com/sethvargo/go-githubactions/... \ - && go mod tidy \ - && go build -o /bin/google-chat-action +RUN go mod tidy && go build \ + -a \ + -trimpath \ + -ldflags "-s -w -extldflags '-static'" \ + -installsuffix cgo \ + -tags netgo \ + -o /bin/google-chat-action \ + . + +RUN strip /bin/google-chat-action + +RUN upx -q -9 /bin/google-chat-action + +FROM scratch + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +COPY --from=builder /bin/google-chat-action /bin/google-chat-action ENTRYPOINT ["/bin/google-chat-action"] diff --git a/Dockerfile.big b/Dockerfile.big new file mode 100644 index 0000000..20cd801 --- /dev/null +++ b/Dockerfile.big @@ -0,0 +1,10 @@ +FROM golang:1.26 + +WORKDIR /src +COPY . . + +RUN go get -u github.com/sethvargo/go-githubactions/... \ + && go mod tidy \ + && go build -o /bin/google-chat-action + +ENTRYPOINT ["/bin/google-chat-action"] diff --git a/README.md b/README.md index b753b09..97d5ff4 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,5 @@ jobs: event_body: "This is a sample TEXT
with a new line" # optional ``` + +TODO - icon_slug diff --git a/docker-slimbuild b/docker-slimbuild deleted file mode 100644 index 6a8459c..0000000 --- a/docker-slimbuild +++ /dev/null @@ -1,31 +0,0 @@ -FROM golang:1.26 AS builder - -RUN apt-get update && apt-get -y install upx - -WORKDIR /app -#RUN mkdir -p $GOPATH/src/github.com/DTherHtun/google-chat-action -#ADD . $GOPATH/src/github.com/DTherHtun/google-chat-action -# RUN go get -u github.com/sethvargo/go-githubactions/... -ENV CGO_ENABLED=0 -COPY . . - -RUN go mod tidy && go build \ - -a \ - -trimpath \ - -ldflags "-s -w -extldflags '-static'" \ - -installsuffix cgo \ - -tags netgo \ - -o /bin/google-chat-action \ - . - -RUN strip /bin/google-chat-action - -RUN upx -q -9 /bin/google-chat-action - -FROM scratch - -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -COPY --from=builder /bin/google-chat-action /bin/google-chat-action - -ENTRYPOINT ["/bin/google-chat-action"]