Skip to content

Commit

Permalink
Add github workflow build
Browse files Browse the repository at this point in the history
  • Loading branch information
xZero707 committed Aug 5, 2023
1 parent 87efa74 commit fc8ac29
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
assignees:
- "xZero707"

# Maintain Docker image dependencies
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "xZero707"
43 changes: 43 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on:
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 16
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.PAT_TOKEN}}
-
name: Build and push
uses: docker/[email protected]
with:
files: build/docker-bake.hcl
push: true
82 changes: 82 additions & 0 deletions build/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
group "default" {
targets = [
"latest"
]
}

target "build-dockerfile" {
dockerfile = "Dockerfile"
}

target "build-platforms" {
platforms = ["linux/amd64"]
}

target "build-common" {
pull = true
}

######################
# Define the variables
######################

variable "REGISTRY_CACHE" {
default = "docker.io/nlss/megacmd-cache"
}

######################
# Define the functions
######################

# Get the arguments for the build
function "get-args" {
params = [version]
result = {
MEGA_DOWNLOAD_URL = version
}
}

# Get the cache-from configuration
function "get-cache-from" {
params = [version]
result = [
"type=registry,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}

# Get the cache-to configuration
function "get-cache-to" {
params = [version]
result = [
"type=registry,mode=max,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
]
}

# Get list of image tags and registries
# Takes a version and a list of extra versions to tag
# eg. get-tags("1.0.0", ["1.0", "latest"])
function "get-tags" {
params = [version, extra_versions]
result = concat(
[
"ghcr.io/n0rthernl1ghts/megacmd:${version}"
],
flatten([
for extra_version in extra_versions : [
"ghcr.io/n0rthernl1ghts/megacmd:${extra_version}"
]
])
)
}

##########################
# Define the build targets
##########################

target "latest" {
inherits = ["build-dockerfile", "build-platforms", "build-common"]
cache-from = get-cache-from("latest")
cache-to = get-cache-to("latest")
tags = get-tags("latest", [])
args = get-args("https://mega.nz/linux/repo/Fedora_38/x86_64/megacmd-Fedora_38.x86_64.rpm")
}

0 comments on commit fc8ac29

Please sign in to comment.