Skip to content

Commit ed86c64

Browse files
authored
Initial Work and CI (#1)
1 parent 0a567cb commit ed86c64

19 files changed

Lines changed: 349 additions & 198 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* webdestroya

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
8+
- package-ecosystem: "gomod"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"
12+
13+
- package-ecosystem: "docker"
14+
directory: "/docker"
15+
schedule:
16+
interval: "daily"

.github/workflows/main.yml

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,39 @@
11
name: "Main"
22

3-
# Only trigger if we changed the files used in the image
3+
# on:
4+
# pull_request:
5+
# types:
6+
# - opened
7+
# - reopened
8+
49
on:
5-
workflow_dispatch:
10+
workflow_call:
611
pull_request:
7-
types:
8-
- opened
9-
- reopened
10-
push:
11-
tags: ['v*']
12-
paths:
13-
- 'remote_shell.sh'
14-
- 'Dockerfile'
15-
16-
env:
17-
REGISTRY: ghcr.io
18-
IMAGE_NAME: ${{ github.repository }}
19-
12+
2013
jobs:
2114
build:
2215
runs-on: ubuntu-latest
23-
permissions:
24-
id-token: write
25-
contents: read
26-
packages: write
16+
17+
strategy:
18+
matrix:
19+
go-version: ['1.19']
20+
2721
steps:
2822

2923
- name: Checkout
3024
uses: actions/checkout@v3
3125

32-
- name: Configure AWS Credentials
33-
uses: aws-actions/configure-aws-credentials@v1
34-
with:
35-
role-to-assume: ${{ secrets.CLOUD87_ECR_PUSH_ROLE_ARN }}
36-
role-session-name: Cloud87DockerRemoteShellGHA
37-
aws-region: us-east-1
38-
39-
- name: Login to Container Registry
40-
if: "startsWith(github.ref, 'refs/tags/v')"
41-
uses: docker/login-action@v2
26+
- name: Set up Go ${{ matrix.go-version }}
27+
uses: actions/setup-go@v3
4228
with:
43-
registry: ${{ env.REGISTRY }}
44-
username: ${{ github.actor }}
45-
password: ${{ github.token }}
46-
47-
- name: Login to Amazon ECR
48-
id: login-ecr
49-
uses: aws-actions/amazon-ecr-login@v1
50-
51-
- name: Set up QEMU
52-
uses: docker/setup-qemu-action@v2
53-
54-
- name: Setup up Docker Buildx
55-
id: buildx
56-
uses: docker/setup-buildx-action@v2
57-
58-
- name: Build Push
59-
uses: docker/build-push-action@v3
60-
with:
61-
context: .
62-
push: startsWith(github.ref, 'refs/tags/v')
63-
platforms: linux/amd64,linux/arm64
64-
tags: |
65-
${{ steps.login-ecr.outputs.registry }}/cloud87/remote-shell:${{ GITHUB_REF_NAME }}
66-
${{ env.REGISTRY }}/${{env.IMAGE_NAME}}:${{ GITHUB_REF_NAME }}
67-
cache-from: type=gha
68-
cache-to: type=gha,mode=max
29+
go-version: ${{ matrix.go-version }}
30+
cache: true
31+
32+
- name: Display Go Version
33+
run: go version
34+
35+
- name: Build
36+
run: go build -a -v
6937

70-
release-github:
71-
name: 'Create GitHub release'
72-
if: "startsWith(github.ref, 'refs/tags/v')"
73-
needs: ['build']
74-
runs-on: 'ubuntu-latest'
75-
permissions:
76-
contents: 'write'
77-
steps:
78-
- name: Release
79-
uses: softprops/action-gh-release@v1
80-
38+
- name: Smoke Test
39+
run: ./remote-shell -version && ./remote-shell --help

.github/workflows/release.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: "Release"
2+
3+
# Only trigger if we changed the files used in the image
4+
on:
5+
workflow_dispatch:
6+
push:
7+
tags: ['v*']
8+
9+
jobs:
10+
11+
basic_smoketest:
12+
name: "Basic Smoke Test"
13+
uses: ./.github/workflows/main.yml
14+
secrets: inherit
15+
16+
docker-release:
17+
name: "Release Docker Image"
18+
runs-on: ubuntu-latest
19+
needs: ['basic_smoketest']
20+
permissions:
21+
contents: read
22+
packages: write
23+
strategy:
24+
matrix:
25+
target:
26+
- Dockerfile: docker/Dockerfile
27+
- Dockerfile: docker/Dockerfile.alpine
28+
steps:
29+
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: Prepare Tags
34+
id: prepare
35+
run: |
36+
TAG=${GITHUB_REF#refs/tags/}
37+
MAJOR_MINOR=${TAG%.*}
38+
MAJOR_ONLY=${TAG%.*.*}
39+
SHORT_COMMIT=${GITHUB_SHA::8}
40+
DATE=$(date '+%Y-%m-%dT%H:%M:%SZ')
41+
echo ::set-output name=tag_name::${TAG}
42+
echo ::set-output name=major_tag::${MAJOR_ONLY}
43+
echo ::set-output name=major_minor_tag::${MAJOR_MINOR}
44+
echo ::set-output name=short_commit::${SHORT_COMMIT}
45+
echo ::set-output name=date::${DATE}
46+
if [[ ${{ matrix.target.Dockerfile }} == *"alpine"* ]]; then
47+
echo ::set-output name=full_tag_name::${TAG}-alpine
48+
echo ::set-output name=full_major_tag::${MAJOR_ONLY}-alpine
49+
echo ::set-output name=full_major_minor_tag::${MAJOR_MINOR}-alpine
50+
echo ::set-output name=latest_tag::latest-alpine
51+
else
52+
echo ::set-output name=full_tag_name::${TAG}
53+
echo ::set-output name=full_major_tag::${MAJOR_ONLY}
54+
echo ::set-output name=full_major_minor_tag::${MAJOR_MINOR}
55+
echo ::set-output name=latest_tag::latest
56+
fi
57+
58+
59+
- name: Log in to the Container registry
60+
uses: docker/login-action@v2
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Set up QEMU
67+
uses: docker/setup-qemu-action@v2
68+
69+
- name: Setup up Docker Buildx
70+
uses: docker/setup-buildx-action@v2
71+
72+
- name: Build and publish ${{ matrix.target.Dockerfile }}
73+
uses: docker/build-push-action@v3
74+
with:
75+
context: .
76+
file: ${{ matrix.target.Dockerfile }}
77+
platforms: linux/amd64,linux/arm64
78+
push: true
79+
build-args: |
80+
BUILD_VERSION=${{ steps.prepare.outputs.tag_name }}
81+
BUILD_SHA=${{ steps.prepare.outputs.short_commit }}
82+
tags: |
83+
ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_tag_name }}
84+
ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_major_tag }}
85+
ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_major_minor_tag }}
86+
ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.latest_tag }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
90+
release-github:
91+
name: 'Create GitHub release'
92+
# if: "startsWith(github.ref, 'refs/tags/v')"
93+
needs: ['docker-release']
94+
runs-on: 'ubuntu-latest'
95+
permissions:
96+
contents: 'write'
97+
steps:
98+
- name: Release
99+
uses: softprops/action-gh-release@v1
100+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
remote_shell
22
remote-shell
33
tryssh.sh
4+
.DS_Store
5+
/vendor
6+
/.vscode

.golangci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
linters:
2+
disable-all: true
3+
enable:
4+
- bodyclose
5+
- errcheck
6+
- gofmt
7+
- goimports
8+
- gosec
9+
- gosimple
10+
- govet
11+
- ineffassign
12+
- misspell
13+
- prealloc
14+
- staticcheck
15+
- typecheck
16+
- unconvert
17+
- unused
18+
- asciicheck
19+
20+
issues:
21+
exclude:
22+
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*\\.Exit|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv|io\\.WriteString|io\\.Copy). is not checked"
23+
exclude-rules:
24+
25+
# Yes, _may_. If they want it.
26+
- text: "G402" # G402: TLS InsecureSkipVerify may be true.
27+
linters:
28+
- gosec
29+
30+
# It's their system
31+
- text: "G204" # G204: Subprocess launched with a potential tainted input or cmd argument
32+
linters:
33+
- gosec
34+
35+
36+
# output configuration options
37+
output:
38+
format: 'colored-line-number'
39+
print-issued-lines: true
40+
print-linter-name: true

Dockerfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2022 Mitch Dempsey
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
build:
2-
docker build --progress plain -t cloud87/remote-shell:latest .
2+
docker build --progress plain -t webdestroya/remote-shell:latest -f docker/Dockerfile .
33

44
buildtest:
5-
docker build -t cloud87/shelltest:latest -f Dockerfile.usage .
5+
docker build -t shelltest:latest -f docker/Dockerfile.usage .
66

77
runtest:
8-
# docker run --rm -p 8722:8722 --privileged -it cloud87/shelltest:latest /bin/bash
98
docker run --rm -p 8722:8722 --privileged cloud87/shelltest:latest /cloud87/bin/remote-shell -user webdestroya
109

1110
runversion:
12-
docker run --rm cloud87/shelltest:latest /cloud87/bin/remote-shell -version
11+
docker run --rm shelltest:latest /cloud87/bin/remote-shell -version
1312

1413
compile:
15-
go build -a -o remote_shell
14+
rm -f remote-shell
15+
go build -a -o remote-shell
1616

1717
compile-version:
1818
go build -ldflags="-X 'main.buildVersion=v1'" -a -o remote-shell
1919

2020
gomod:
2121
go mod tidy
22+
23+
lint:
24+
docker run --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.49.0 golangci-lint run -v

0 commit comments

Comments
 (0)