Skip to content

Commit 98d26d9

Browse files
dag-andersenDag Andersen
authored and
Dag Andersen
committed
Init
0 parents  commit 98d26d9

36 files changed

+4046
-0
lines changed

.github/workflows/build-and-push.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and Push on tag
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build-amd64:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
- name: Login to Docker Hub
19+
uses: docker/login-action@v3
20+
with:
21+
username: ${{ secrets.DOCKERHUB_USERNAME }}
22+
password: ${{ secrets.DOCKERHUB_TOKEN }}
23+
- name: Set env
24+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
25+
- name: Build and push # tag with git tag
26+
run: |
27+
docker buildx build --platform=linux/amd64 -f ./Dockerfile_AMD64 . -t dagandersen/argocd-diff-preview:${RELEASE_VERSION}-amd64 --push
28+
29+
build-arm64:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Set up QEMU
35+
uses: docker/setup-qemu-action@v3
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
- name: Login to Docker Hub
39+
uses: docker/login-action@v3
40+
with:
41+
username: ${{ secrets.DOCKERHUB_USERNAME }}
42+
password: ${{ secrets.DOCKERHUB_TOKEN }}
43+
- name: Set env
44+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
45+
- name: Build and push # tag with git tag
46+
run: |
47+
docker buildx build --platform=linux/arm64 -f ./Dockerfile_ARM64 . -t dagandersen/argocd-diff-preview:${RELEASE_VERSION}-arm64 --push
48+
49+
create-manifest:
50+
runs-on: ubuntu-latest
51+
needs: [build-amd64, build-arm64]
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
- name: Set up QEMU
56+
uses: docker/setup-qemu-action@v3
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
- name: Login to Docker Hub
60+
uses: docker/login-action@v3
61+
with:
62+
username: ${{ secrets.DOCKERHUB_USERNAME }}
63+
password: ${{ secrets.DOCKERHUB_TOKEN }}
64+
- name: Set env
65+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
66+
- name: create manifest
67+
run: |
68+
docker buildx imagetools create -t \
69+
dagandersen/argocd-diff-preview:${RELEASE_VERSION} \
70+
dagandersen/argocd-diff-preview:${RELEASE_VERSION}-amd64 \
71+
dagandersen/argocd-diff-preview:${RELEASE_VERSION}-arm64
72+
docker buildx imagetools create -t \
73+
dagandersen/argocd-diff-preview:latest \
74+
dagandersen/argocd-diff-preview:${RELEASE_VERSION}-amd64 \
75+
dagandersen/argocd-diff-preview:${RELEASE_VERSION}-arm64

.github/workflows/generate-diff.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Generate Diff
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions: write-all
13+
14+
steps:
15+
- name: Check out the repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
path: pull-request
23+
24+
- uses: actions/checkout@v4
25+
with:
26+
ref: main
27+
path: main
28+
29+
- name: Diff
30+
run: |
31+
docker run \
32+
--network=host \
33+
-v /var/run/docker.sock:/var/run/docker.sock \
34+
-v $(pwd)/main:/base-branch \
35+
-v $(pwd)/pull-request:/target-branch \
36+
-v $(pwd)/output:/output \
37+
-e TARGET_BRANCH=${{ github.head_ref }} \
38+
-e GIT_REPO="https://github.com/dag-andersen/argocd-diff-preview.git" \
39+
dagandersen/argocd-diff-preview:latest
40+
41+
- name: Post diff as comment
42+
run: |
43+
gh pr comment ${{ github.event.number }} --edit-last --body-file output/diff.md \
44+
|| gh pr comment ${{ github.event.number }} --body-file output/diff.md
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Tests and release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
env:
8+
CRATE_NAME: argocd-diff-preview
9+
GITHUB_TOKEN: ${{ github.token }}
10+
RUST_BACKTRACE: 1
11+
12+
jobs:
13+
test:
14+
name: ${{ matrix.platform.os_name }} with rust
15+
runs-on: ${{ matrix.platform.os }}
16+
permissions:
17+
contents: write
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
platform:
22+
- os_name: Linux-x86_64
23+
os: ubuntu-20.04
24+
target: x86_64-unknown-linux-musl
25+
bin: argocd-diff-preview
26+
name: argocd-diff-preview-Linux-x86_64-musl.tar.gz
27+
- os_name: Linux-aarch64
28+
os: ubuntu-20.04
29+
target: aarch64-unknown-linux-musl
30+
bin: argocd-diff-preview
31+
name: argocd-diff-preview-Linux-aarch64-musl.tar.gz
32+
- os_name: Linux-arm
33+
os: ubuntu-20.04
34+
target: arm-unknown-linux-musleabi
35+
bin: argocd-diff-preview
36+
name: argocd-diff-preview-Linux-arm-musl.tar.gz
37+
- os_name: macOS-x86_64
38+
os: macOS-latest
39+
target: x86_64-apple-darwin
40+
bin: argocd-diff-preview
41+
name: argocd-diff-preview-Darwin-x86_64.tar.gz
42+
- os_name: macOS-aarch64
43+
os: macOS-latest
44+
target: aarch64-apple-darwin
45+
bin: argocd-diff-preview
46+
name: argocd-diff-preview-Darwin-aarch64.tar.gz
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Cache cargo & target directories
50+
uses: Swatinem/rust-cache@v2
51+
- name: Install musl-tools on Linux
52+
if: contains(matrix.platform.name, 'musl')
53+
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
54+
- name: Build binary
55+
uses: houseabsolute/actions-rust-cross@v0
56+
with:
57+
command: "build"
58+
target: ${{ matrix.platform.target }}
59+
toolchain: stable
60+
args: "--locked --release"
61+
strip: true
62+
- name: Package as archive
63+
shell: bash
64+
run: |
65+
cd target/${{ matrix.platform.target }}/release
66+
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
67+
cd -
68+
- name: Publish release artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: argocd-diff-preview-${{ matrix.platform.os_name }}
72+
path: "argocd-diff-preview-*"
73+
- name: Publish GitHub release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
draft: true
77+
files: "argocd-diff-preview-*"
78+
if: startsWith( github.ref, 'refs/tags/v' )

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
target/
3+
argocd/
4+
secrets/
5+
output/

0 commit comments

Comments
 (0)