Skip to content

Commit

Permalink
Merge pull request #2 from RAHB-REALTORS-Association/timezone
Browse files Browse the repository at this point in the history
Add --now Flag and Timezone Support
  • Loading branch information
justinh-rahb committed Sep 26, 2023
2 parents 79bf212 + 445a1af commit f392f07
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 63 deletions.
25 changes: 25 additions & 0 deletions .do/deploy.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
spec:
name: member-counts-go
services:
- name: member-counts-service
git:
branch: main
repo_clone_url: https://github.com/RAHB-REALTORS-Association/member-counts-go.git
envs:
- key: REDASH_BASE_URL
value: "<Your_Redash_Base_URL>"
type: SECRET
- key: REDASH_API_KEY
value: "<Your_Redash_API_Key>"
type: SECRET
- key: REDASH_QUERY_ID
value: "<Your_Redash_Query_ID>"
- key: GOOGLE_CHAT_WEBHOOK_URL
value: "<Your_Google_Chat_Webhook_URL>"
type: SECRET
- key: SCHEDULE_HOUR
value: "<Your_Schedule_Hour>"
- key: SCHEDULE_MINUTE
value: "<Your_Schedule_Minute>"
- key: TIMEZONE
value: "<Your_Timezone>"
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.md
*.yml
*.yaml
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve the console app
title: '[Bug] '
labels: 'bug'
assignees: 'justinh-rahb'

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Run the command '...'
2. Use the flag '....'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Console Output**
If applicable, add the console output to help explain your problem.

**Environment (please complete the following information):**
- OS: [e.g. Windows, macOS, Linux]
- Version [e.g. 10, 11.4]
- Go Version [e.g. 1.20]

**Additional context**
Add any other context about the problem here, such as specific conditions or configurations that cause the bug to appear.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for improving the console app
title: '[Feature Request] '
labels: 'enhancement'
assignees: 'justinh-rahb'

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. It would be beneficial if [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Environment (Optional)**
- OS: [e.g. Windows, macOS, Linux]
- Version: [e.g. 10, 11.4]
- Go Version: [e.g. 1.20]

**Additional context**
Add any other context or screenshots about the feature request here, such as specific conditions or configurations that would benefit from the feature.
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Summary
Describe the changes made in this PR.

## Description
Provide a detailed description of the changes. Include the context and reasons for the changes made.

## Related Issue(s)
Link to the related issue(s).

## Motivation and Context
Explain why these changes were necessary.

## Types of changes
What types of changes does your code introduce? Put an `x` in all the boxes that apply:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:
Go over all the following points, and put an `x` in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build for Linux
run: go build -o member-counts-go ./...

- name: Build for Mac
run: GOOS=darwin GOARCH=amd64 go build -o member-counts-go-mac ./...

- name: Build for Windows
run: GOOS=windows GOARCH=amd64 go build -o member-counts-go.exe ./...

- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
body: "## Release: ${{ github.ref_name }}"
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset (Linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./member-counts-go
asset_name: member-counts-go
asset_content_type: application/octet-stream

- name: Upload Release Asset (Mac)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./member-counts-go-mac
asset_name: member-counts-go-mac
asset_content_type: application/octet-stream

- name: Upload Release Asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./member-counts-go.exe
asset_name: member-counts-go.exe
asset_content_type: application/octet-stream
44 changes: 44 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "CodeQL"

on:
workflow_dispatch:
schedule:
- cron: '21 23 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ['go']

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# Go does not require a build step, and this action will attempt to build Go projects by default.
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# Remove the Install dependencies step as it's not necessary for a Go project.
# If your project has specific build steps, replace the Autobuild step with those.
# For example, if you use Go modules:
# - name: Build Project
# run: go build ./...

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker

on:
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'Dockerfile'
create:

env:
REGISTRY: ghcr.io
IMAGE_NAME: rahb-realtors-association/member-counts-go

jobs:
build-and-push-image:
if: github.event_name == 'push' || (github.event_name == 'create' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=sha,format=long
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Continuous Integration

on:
push:
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ go.work

.env

main
main
member-counts-go
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use the official Go image from the DockerHub
FROM golang:1.20

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy go mod and sum files to the app directory
COPY go.mod go.sum ./

# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download

# Copy the source code into the container
COPY . .

# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o member-counts-go .

# Start fresh from a smaller image
FROM alpine:latest

# Security related setting, see https://stackoverflow.com/questions/52215283/what-is-the-use-of-user-nobody-in-dockerfile
RUN apk --no-cache add ca-certificates && addgroup -S app && adduser -S -G app app
USER app

# Copy the Pre-built binary file from the previous stage
COPY --from=0 /app/member-counts-go .

# Command to run the executable
ENTRYPOINT ["./member-counts-go"]
Loading

0 comments on commit f392f07

Please sign in to comment.