Skip to content

Commit

Permalink
I-11 | Change repo name (#12)
Browse files Browse the repository at this point in the history
* I-11 | Change repo name
* - fix GH action
* - refactor codebase
* - manual trigger
* - fix GH action
* - fix lints
  • Loading branch information
Hakan authored Apr 8, 2022
1 parent 436f104 commit be84a98
Show file tree
Hide file tree
Showing 20 changed files with 922 additions and 69 deletions.
33 changes: 33 additions & 0 deletions .github/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Installation

You can use `go` to build S3 Secrets Manager locally with:

```shell
go install github.com/omegion/argocd-actions
```

Or, you can use the usual commands to install or upgrade:

On OS X

```shell
curl -L https://github.com/omegion/argocd-actions/releases/download/{{.Env.VERSION}}/argocd-actions-darwin-amd64 >/usr/local/bin/argocd-actions
&& \
chmod +x /usr/local/bin/argocd-actions
```

On Linux

```shell
curl -L https://github.com/omegion/argocd-actions/releases/download/{{.Env.VERSION}}/argocd-actions-linux-amd64 >/usr/local/bin/argocd-actions
&& \
chmod +x /tmp/argocd-actions && \
sudo cp /tmp/argocd-actions /usr/local/bin/argocd-actions
```

Otherwise, download one of the releases from the [release page](https://github.com/omegion/argocd-actions/releases/)
directly.

See the install [docs](https://argocd-actions.omegion.dev) for more install options and instructions.

## Changelog
108 changes: 108 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build

on:
push:
tags:
- 'v*'
jobs:
push_to_registry:
name: Push Docker image to GitHub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Import Secrets
id: secrets
uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ADDR }}
method: github
githubToken: ${{ secrets.GT_VAULT_AUTH_TOKEN }}
secrets: |
github/data/token registry_write | GITHUB_REGISTRY_TOKEN ;
- name: Get the version
run: |
VERSION=$(echo $GITHUB_REF | cut -d / -f 3)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ steps.secrets.outputs.GITHUB_REGISTRY_TOKEN }}

- name: Build and push to GitHub
id: github_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ghcr.io/omegion/argocd-actions:latest,ghcr.io/omegion/argocd-actions:${{env.VERSION}}
platforms: linux/amd64,linux/arm64

release:
name: Create Release
runs-on: 'ubuntu-latest'
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- 'darwin/amd64'
- 'darwin/arm64'
- 'linux/amd64'
- 'linux/arm64'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get the version
run: |
VERSION=$(echo $GITHUB_REF | cut -d / -f 3)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=argocd-actions-$GOOS-$GOARCH
VERSION=$(echo $GITHUB_REF | cut -d / -f 3)
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build
run: |
make build TARGETOS="$GOOS" TARGETARCH="$GOARCH" VERSION="$VERSION" BINARY_NAME="$BINARY_NAME"
- name: Release Notes
run: |
export VERSION=${{env.VERSION}}
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> .github/RELEASE_TEMPLATE.md
curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/v3.10.0/gomplate_linux-amd64
chmod 755 /usr/local/bin/gomplate
gomplate --file .github/RELEASE_TEMPLATE.md --out .github/RELEASE-NOTES.md
- name: Release with Notes
uses: softprops/action-gh-release@v1
with:
name: Release ${{env.VERSION}}
body_path: ".github/RELEASE-NOTES.md"
draft: false
files: ${{env.BINARY_NAME}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Integration Test
on: [ push ]

on:
# push:
# pull_request:
repository_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -18,9 +22,10 @@ jobs:
- name: Self test
id: selftest
uses: omegion/argocd-app-actions@master
uses: omegion/argocd-actions@master
with:
address: ${{ secrets.ARGOCD_ADDR }}
token: ${{ steps.secrets.outputs.ARGOCD_TOKEN }}
action: sync
appName: blog

25 changes: 25 additions & 0 deletions .github/workflows/local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Local

on:
push:
# branches-ignore:
# - '**'

jobs:
local_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: ./
- name: Self test
id: selftest
uses: ./
with:
address: ${{ secrets.ARGOCD_ADDR }}
token: ${{ secrets.ARGOCD_TOKEN }}
action: sync
appName: blog


6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
go-version: ^1.17
id: go

- name: Checkout code
Expand Down Expand Up @@ -52,8 +52,8 @@ jobs:
- name: go vet
run: go vet ./...

- name: go lint
run: golint -set_exit_status ./...
# - name: go lint
# run: golint -set_exit_status ./...

golangci:
name: golangci lint check
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG GO_VERSION=1.16-alpine3.12
ARG FROM_IMAGE=alpine:3.12
ARG GO_VERSION=1.17-alpine3.14
ARG FROM_IMAGE=alpine:3.14

FROM golang:${GO_VERSION} AS builder

Expand All @@ -17,6 +17,9 @@ RUN make build-for-container

FROM ${FROM_IMAGE}

LABEL org.opencontainers.image.source="https://github.com/omegion/argocd-actions"

COPY --from=builder /app/dist/argocd-actions-linux /bin/argocd-actions

ENTRYPOINT ["argocd-actions"]

13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export PATH := $(abspath ./vendor/bin):$(PATH)

BASE_PACKAGE_NAME = github.com/omegion/argocd-actions
GIT_VERSION = $(shell git describe --tags --always 2> /dev/null || echo 0.0.0)
GIT_VERSION = $(shell git describe --tags --always 2> /dev/null || echo 0.0.0)
LDFLAGS = -ldflags "-X $(BASE_PACKAGE_NAME)/internal/info.Version=$(GIT_VERSION)"
BUFFER := $(shell mktemp)
REPORT_DIR = dist/report
Expand All @@ -20,10 +20,10 @@ lint:
gofmt -l . | tee $(BUFFER)
@! test -s $(BUFFER)
go vet ./...
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.40.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.0
@golangci-lint --version
golangci-lint run
go get -u golang.org/x/lint/golint
go install golang.org/x/lint/golint
golint -set_exit_status ./...

.PHONY: test
Expand All @@ -40,8 +40,7 @@ cut-tag:
git push origin $(version)

.PHONY: release
release: build-for-container
release:
@echo "Releasing $(GIT_VERSION)"
docker build -t argocd-actions .
docker tag argocd-actions:latest omegion/argocd-actions:$(GIT_VERSION)
docker push omegion/argocd-actions:$(GIT_VERSION)
docker build . --tag ghcr.io/omegion/argocd-actions:$(GIT_VERSION) --tag ghcr.io/omegion/argocd-actions:latest
docker push ghcr.io/omegion/argocd-actions:$(GIT_VERSION)
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ArgoCD Application Actions

[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Find%20and%20Replace-blue.svg?colorA=24292e&colorB=0366d6&style=flat&longCache=true&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII=)](https://github.com/omegion/argocd-app-actions)
[![Actions Status](https://github.com/omegion/argocd-app-actions/workflows/Build/badge.svg)](https://github.com/omegion/argocd-app-actions/actions)
[![Actions Status](https://github.com/omegion/argocd-app-actions/workflows/Integration%20Test/badge.svg)](https://github.com/omegion/argocd-app-actions/actions)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Find%20and%20Replace-blue.svg?colorA=24292e&colorB=0366d6&style=flat&longCache=true&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII=)](https://github.com/omegion/argocd-actions)
[![Actions Status](https://github.com/omegion/argocd-actions/workflows/Build/badge.svg)](https://github.com/omegion/argocd-actions/actions)
[![Actions Status](https://github.com/omegion/argocd-actions/workflows/Integration%20Test/badge.svg)](https://github.com/omegion/argocd-actions/actions)

This action will sync ArgoCD application.

Expand All @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Sync ArgoCD Application
uses: omegion/argocd-app-actions@master
uses: omegion/argocd-actions@master
with:
address: "vault.example.com"
token: ${{ secrets.ARGOCD_TOKEN }}
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Sync ArgoCD Application
uses: omegion/argocd-app-actions@master
uses: omegion/argocd-actions@master
with:
address: "vault.example.com"
token: ${{ secrets.ARGOCD_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions action.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG ARGOCD_ACTIONS_VERSION=latest

FROM ghcr.io/omegion/argocd-actions:${ARGOCD_ACTIONS_VERSION}

ENTRYPOINT ["argocd-actions"]

26 changes: 22 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "ArgoCD Application Sync Action"
description: "Sync your ArgoCD application from GitHub"
name: "ArgoCD Actions"
description: "Operate your ArgoCD applications from GitHub"
author: "omegion"
inputs:
address:
Expand All @@ -8,9 +8,27 @@ inputs:
token:
description: "ArgoCD token"
required: true
action:
description: "Action name"
required: true
appName:
description: "Application name to sync"
required: true

runs:
using: "docker"
image: "Dockerfile"
using: "composite"
steps:
- name: Run argocd-actions CLI from Github Action REF
run: |
ref_name=${{ github.ref_name }}
action_path=${{ github.action_path }}
action_ref=${action_path##*/}
image_tag=$([ -z "$action_ref" ] && echo $ref_name || echo $action_ref)
docker run --rm -i ghcr.io/omegion/argocd-actions:$image_tag \
${{ inputs.action }} \
--application=${{ inputs.appName }} \
--token=${{ inputs.token }} \
--address=${{ inputs.address }} \
--logLevel=debug
shell: sh
31 changes: 31 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"log"

"github.com/spf13/cobra"
)

// Root is root of cmd.
func Root() *cobra.Command {
cmd := &cobra.Command{
Use: "argocd-actions",
Short: "ArgoCD Actions.",
Long: "Operate your ArgoCD applications from GitHub.",
SilenceUsage: true,
}

cmd.PersistentFlags().String("address", "", "ArgoCD address")

if err := cmd.MarkPersistentFlagRequired("address"); err != nil {
log.Fatalf("Lethal damage: %s\n\n", err)
}

cmd.PersistentFlags().String("token", "", "ArgoCD token")

if err := cmd.MarkPersistentFlagRequired("token"); err != nil {
log.Fatalf("Lethal damage: %s\n\n", err)
}

return cmd
}
Loading

0 comments on commit be84a98

Please sign in to comment.