Compare commits
83 Commits
Author | SHA1 | Date | |
---|---|---|---|
559b854f02 | |||
f1d2410857 | |||
d01e6a050f | |||
1475c7911f | |||
af9dee255c | |||
ef3fc3987a | |||
9058e3c6fc | |||
6b87fde7d1 | |||
e27ac12296 | |||
41909503fa | |||
3fb9332e10 | |||
b6a6ca589c | |||
a152670456 | |||
0db3ab00d2 | |||
fc56a2ea9e | |||
20b90ebbcd | |||
58719e8495 | |||
26dec18f85 | |||
910381666e | |||
481835276f | |||
8294758bb6 | |||
82d1328f8f | |||
7ec2ab1102 | |||
c2c1ec925a | |||
b7dcaca6cc | |||
6b0f6948d2 | |||
b627fcf3d9 | |||
6a42857c8c | |||
00ed8b2907 | |||
14136a1e26 | |||
c289808993 | |||
769828c98a | |||
737b0c2c87 | |||
60e1a2c7f4 | |||
31530c2f3b | |||
f1bd836a0a | |||
b8b4771e04 | |||
e6b1935fb0 | |||
d64727a6d5 | |||
918ca14eca | |||
d0016b9a9b | |||
75172b995c | |||
fe09039377 | |||
5154f87d53 | |||
304c2f0622 | |||
2d8da3e77c | |||
3c866fd944 | |||
f342d10b83 | |||
43f8018db2 | |||
a7fe3e5e66 | |||
46f3caf277 | |||
fe0f911ec7 | |||
99622c5cc0 | |||
e7bcd8d016 | |||
df78e07bd1 | |||
494b30b1c5 | |||
27a2abc35c | |||
471fc092ce | |||
355e229212 | |||
78d0e72c2c | |||
8039badd88 | |||
57aa34186b | |||
1aba36467a | |||
09b11a9f80 | |||
9638f3c402 | |||
3d05c7de1d | |||
b6d88a0ae8 | |||
0e3ef7d956 | |||
45689f8c0e | |||
4d76b1e99f | |||
9a7feafa51 | |||
39365fe0a6 | |||
d2a16d5533 | |||
b4c00aafaf | |||
a76e888c5c | |||
e05d1683c6 | |||
08c9147f50 | |||
e6abc692eb | |||
05aae5c7df | |||
86605f009f | |||
e326624924 | |||
45d5a2348f | |||
af723ea42e |
75
.github/workflows/CD.yml
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
name: Deploy Project
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Application Version
|
||||
type: string
|
||||
required: true
|
||||
env:
|
||||
description: Deployment Environment
|
||||
type: string
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
# - name: Dump inputs context
|
||||
# env:
|
||||
# INPUTS_CONTEXT: ${{ toJson(inputs) }}
|
||||
|
||||
- name: Dump Inputs context
|
||||
env:
|
||||
INPUTS_CONTEXT: ${{ toJson(inputs) }}
|
||||
run: echo "$INPUTS_CONTEXT"
|
||||
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
|
||||
- name: Dump job context
|
||||
env:
|
||||
JOB_CONTEXT: ${{ toJson(job) }}
|
||||
run: echo "$JOB_CONTEXT"
|
||||
|
||||
- name: Dump steps context
|
||||
env:
|
||||
STEPS_CONTEXT: ${{ toJson(steps) }}
|
||||
run: echo "$STEPS_CONTEXT"
|
||||
|
||||
- name: Dump runner context
|
||||
env:
|
||||
RUNNER_CONTEXT: ${{ toJson(runner) }}
|
||||
run: echo "$RUNNER_CONTEXT"
|
||||
|
||||
- name: Dump strategy context
|
||||
env:
|
||||
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
|
||||
run: echo "$STRATEGY_CONTEXT"
|
||||
|
||||
- name: Dump matrix context
|
||||
env:
|
||||
MATRIX_CONTEXT: ${{ toJson(matrix) }}
|
||||
run: echo "$MATRIX_CONTEXT"
|
||||
|
||||
- name: Setup SSH
|
||||
shell: bash
|
||||
run: |
|
||||
whoami
|
||||
eval `ssh-agent -s`
|
||||
mkdir -p ~/.ssh/
|
||||
touch ~/.ssh/id_rsa
|
||||
echo "${{secrets.SSH_KEY}}" | tr -d '\r' > ~/.ssh/id_rsa
|
||||
chmod 700 ~/.ssh/id_rsa
|
||||
ssh-keyscan -t rsa,dsa,ecdsa,ed25519 ${{secrets.SSH_HOST}} >> ~/.ssh/known_hosts
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
- name: SSH to the Prod env
|
||||
shell: bash
|
||||
run: |
|
||||
ssh -tt -o StrictHostKeyChecking=no gitea@${{secrets.SSH_HOST}} 'docker pull docker.savin.nyc/go-receipt-tracker:nightly'
|
||||
ssh -tt -o StrictHostKeyChecking=no gitea@${{secrets.SSH_HOST}} 'cd /opt/projects/receipt-tracker && docker compose down --remove-orphans && docker compose up -d'
|
143
.github/workflows/CI.yml
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- develop
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
|
||||
jobs:
|
||||
|
||||
testing:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.24.x
|
||||
os:
|
||||
- ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
go get -u .
|
||||
go test ./.
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ testing ]
|
||||
steps:
|
||||
|
||||
- name: Extract Version
|
||||
id: version_step
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT
|
||||
echo RELEASE_DATE=$(date --rfc-3339=date) >> ${GITHUB_ENV}
|
||||
echo COMMIT_SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-10) >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
|
||||
- name: Dump job context
|
||||
env:
|
||||
JOB_CONTEXT: ${{ toJson(job) }}
|
||||
run: echo "$JOB_CONTEXT"
|
||||
|
||||
- name: Dump steps context
|
||||
env:
|
||||
STEPS_CONTEXT: ${{ toJson(steps) }}
|
||||
run: echo "$STEPS_CONTEXT"
|
||||
# echo "##[set-output name=version;]VERSION=${GITHUB_REF#$"refs/tags/v"}"
|
||||
# echo "##[set-output name=version_tag;]$GITHUB_REPOSITORY:${GITHUB_REF#$"refs/tags/v"}"
|
||||
# echo "##[set-output name=latest_tag;]$GITHUB_REPOSITORY:latest"
|
||||
# - name: Print Version
|
||||
# run: |
|
||||
# echo ${{steps.version_step.outputs.version_tag}}
|
||||
# echo ${{steps.version_step.outputs.latest_tag}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker BuildX
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: |
|
||||
linux/amd64
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: docker.savin.nyc
|
||||
username: ${{ vars.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# - name: PrepareReg Names
|
||||
# id: read-docker-image-identifiers
|
||||
# run: |
|
||||
# echo VERSION_TAG=$(echo ${{ steps.version_step.outputs.version_tag }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||
# echo LASTEST_TAG=$(echo ${{ steps.version_step.outputs.latest_tag }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||
|
||||
- name: Build and Push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
# context: .
|
||||
# file: ./Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
docker.savin.nyc/${{ github.event.repository.name }}:nightly
|
||||
docker.savin.nyc/${{ github.event.repository.name }}:${{ steps.version_step.outputs.COMMIT_SHA_SHORT }}
|
||||
# ${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }}
|
||||
# latest
|
||||
# build-args: |
|
||||
# docker.savin.nyc/${{ github.event.repository.name }}:latest
|
||||
# build-args: |
|
||||
# ${{steps.version_step.outputs.version}}
|
||||
# docker.savin.nyc/${{ github.event.repository.name }}:${{ env.RELEASE_VERSION }}
|
||||
# tags: |
|
||||
# ${{env.VERSION_TAG}}
|
||||
# ${{env.LASTEST_TAG}}
|
||||
|
||||
- name: Auto Execute a Workflow
|
||||
run: |
|
||||
echo "URL: http://10.10.11.26:8090/api/v1/repos/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/actions/workflows/CD.yml/dispatches"
|
||||
curl -X 'POST' \
|
||||
'http://10.10.11.26:8090/api/v1/repos/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/actions/workflows/CD.yml/dispatches' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Basic ${{ secrets.AUTH_BASIC }}' \
|
||||
-H 'Authorization: token ${{ secrets.GHA_TOKEN }}' \
|
||||
-d '{"ref":"${{ github.ref }}","inputs":{"version":"${{ steps.version_step.outputs.COMMIT_SHA_SHORT }}","env":"${{ github.ref_name}}"}}'
|
||||
shell: bash
|
||||
with:
|
||||
debug: true
|
||||
# - name: Auto Deploy (Dev)
|
||||
## if: ${{ contains(github.ref, 'develop') and env.AUTO_DEPLOY_DEV == 'true' }}
|
||||
# id: auto-deploy-dev
|
||||
# uses: https://git.savin.nyc/gh-actions/auto-exec-workflow@v1
|
||||
# with:
|
||||
# GITEA_TOKEN: ${{ secrets.GHA_TOKEN }}
|
||||
# Version: ${{ steps.version.output.updated-version }}
|
||||
|
||||
- name: Output Summary
|
||||
id: output-summary
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CI pipeline has been compiled for ${{ github.repository }} with a new version ${{ steps.vars.outputs.COMMIT_SHORT_SHA }}" >> $GITHUB_STEP_SUMMARY
|
63
.github/workflows/build.yml
vendored
@ -1,63 +0,0 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [develop]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- '.github/**'
|
||||
pull_request:
|
||||
branches: [develop]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- '.github/**'
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
# needs: test
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
steps:
|
||||
- name: Extract Version
|
||||
id: version_step
|
||||
run: |
|
||||
echo "##[set-output name=version;]VERSION=${GITHUB_REF#$"refs/tags/v"}"
|
||||
echo "##[set-output name=version_tag;]$GITHUB_REPOSITORY:${GITHUB_REF#$"refs/tags/v"}"
|
||||
echo "##[set-output name=latest_tag;]$GITHUB_REPOSITORY:latest"
|
||||
|
||||
- name: Print Version
|
||||
run: |
|
||||
echo ${{steps.version_step.outputs.version_tag}}
|
||||
echo ${{steps.version_step.outputs.latest_tag}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: docker.savin.nyc
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: PrepareReg Names
|
||||
id: read-docker-image-identifiers
|
||||
run: |
|
||||
echo VERSION_TAG=$(echo ${{ steps.version_step.outputs.version_tag }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||
echo LASTEST_TAG=$(echo ${{ steps.version_step.outputs.latest_tag }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
${{env.VERSION_TAG}}
|
||||
${{env.LASTEST_TAG}}
|
||||
build-args: |
|
||||
${{steps.version_step.outputs.version}}
|
||||
registry.akaiv.io/${{ github.event.repository.name }}:latest
|
||||
registry.akaiv.io/${{ github.event.repository.name }}:${{ env.RELEASE_VERSION }}
|
43
.github/workflows/testing.yml
vendored
@ -1,43 +0,0 @@
|
||||
name: Testing
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.23.x]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
go get -u .
|
||||
go test ./.
|
||||
|
||||
# test-cache:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/setup-go@v3
|
||||
# with:
|
||||
# go-version: 1.20.x
|
||||
# - uses: actions/checkout@v3
|
||||
# - uses: actions/cache@v3
|
||||
# with:
|
||||
# # In order:
|
||||
# # * Module download cache
|
||||
# # * Build cache (Linux)
|
||||
# # * Build cache (Mac)
|
||||
# # * Build cache (Windows)
|
||||
# path: |
|
||||
# ~/go/pkg/mod
|
||||
# ~/.cache/go-build
|
||||
# ~/Library/Caches/go-build
|
||||
# ~\AppData\Local\go-build
|
||||
# key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
# restore-keys: |
|
||||
# ${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
# - run: go test ./...
|
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
*.jpg
|
||||
*.jpeg
|
||||
*.png
|
||||
*.gif
|
||||
go-receipt-tracker
|
||||
config.*
|
35
Dockerfile
Normal file
@ -0,0 +1,35 @@
|
||||
# builder
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
ADD . /app
|
||||
|
||||
RUN CGO_ENABLED=0 go build -o go-receipt-tracker
|
||||
|
||||
# runner
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/go-receipt-tracker /app/go-receipt-tracker
|
||||
|
||||
# Metadata params
|
||||
ARG VERSION
|
||||
ARG BUILD_DATE
|
||||
ARG NAME
|
||||
ARG VENDOR
|
||||
|
||||
# Metadata
|
||||
LABEL org.label-schema.build-date=$BUILD_DATE \
|
||||
org.label-schema.url="https://alex.savin.nyc" \
|
||||
org.label-schema.docker.schema-version="1.0"
|
||||
# org.label-schema.name=$NAME \
|
||||
# org.label-schema.description="Example of multi-stage docker build" \
|
||||
# org.label-schema.vcs-url=https://github.com/alex-savin/$VCS_URL \
|
||||
# org.label-schema.vcs-ref=$VCS_REF \
|
||||
# org.label-schema.vendor=$VENDOR \
|
||||
# org.label-schema.version=$VERSION \
|
||||
|
||||
VOLUME /app/blobs
|
||||
VOLUME /app/config
|
||||
|
||||
CMD ["./go-receipt-tracker"]
|
0
blobs/.gitkeep
Normal file
Before Width: | Height: | Size: 182 KiB |
Before Width: | Height: | Size: 187 KiB |
Before Width: | Height: | Size: 210 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 214 KiB |
Before Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 202 KiB |
Before Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 175 KiB |
Before Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 202 KiB |
Before Width: | Height: | Size: 110 KiB |
Before Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 218 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 189 KiB |
Before Width: | Height: | Size: 169 KiB |
Before Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 154 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 219 KiB |
Before Width: | Height: | Size: 110 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 157 KiB |
Before Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 314 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 222 KiB |
Before Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 171 KiB |
Before Width: | Height: | Size: 218 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 261 KiB |
Before Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 161 KiB |
Before Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 200 KiB |