From d3ce6af94412e76326acdca664981d69bcbc9d87 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 25 Mar 2020 23:13:26 +0100 Subject: [PATCH] init --- .github/workflows/test.yml | 16 ++++++++++++++ Dockerfile | 8 +++---- LICENSE | 2 +- README.md | 14 +++++++++--- action.yml | 25 +++++++++++---------- entrypoint.sh | 3 --- main.sh | 45 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100755 entrypoint.sh create mode 100755 main.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..34fadbf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: Test Action + +on: push + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Clone repo + run: git clone https://salsa.debian.org/ruby-team/lolcat.git -b debian/100.0.1-2 + - name: Test run + uses: ./ + with: + directory: lolcat \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index af66730..af73830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ -FROM alpine:3.10 +FROM docker -COPY LICENSE README.md / +COPY main.sh / -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/main.sh"] diff --git a/LICENSE b/LICENSE index a67dca8..38195be 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The MIT License (MIT) -Copyright (c) 2018 GitHub, Inc. and contributors +Copyright (c) 2020 Dawid Dziurla Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 25842b5..b3ae87e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ -# Container Action Template +# Build Debian package Github Action -To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/). +An action that builds a Debian package from source for specified distribution. -For info on how to build your first Container action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/container-action.md). +## Usage + +```yaml +- name: Build Debian package + uses: dawidd6/action-debian-package@master + with: + directory: ./ + os: debian +``` diff --git a/action.yml b/action.yml index 4353abb..ab604de 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,15 @@ -name: 'Container Action Template' -description: 'Get started with Container actions' -author: 'GitHub' -inputs: - myInput: - description: 'Input to use' - default: 'world' +name: Build Debian package +description: Build Debian package from source for selected target release +branding: + color: red + icon: package +inputs: + directory: + description: Directory where Debianized sources live (defaults to current) + required: false + os: + description: '"ubuntu" or "debian" (defaults to "debian")' + required: false runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.myInput }} + using: docker + image: Dockerfile diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 3b8cd2d..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -l - -echo "hello $1" diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..8a584a5 --- /dev/null +++ b/main.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +directory="${INPUT_DIRECTORY:-$PWD}" +os="${INPUT_OS:-"debian"}" + +cd "$directory" + +package="$(dpkg-parsechangelog -S Source)" +version="$(dpkg-parsechangelog -S Version)" +distribution="$(dpkg-parsechangelog -S Distribution | sed 's/UNRELEASED/unstable/')" + +container="builder" +image="$os:$distribution" +workdir="/build/source" + +docker create \ + --name "$container" \ + --volume "$directory":"$workdir" \ + --workdir "$workdir" \ + "$image" \ + sleep inf + +docker exec \ + --tty \ + "$container" \ + apt-get update + +docker exec \ + --tty \ + "$container" \ + apt-get install dpkg-dev debhelper + +docker exec \ + --tty \ + --workdir "$workdir" \ + "$container" \ + apt-get build-dep ./ + +docker exec \ + --tty \ + --workdir "$workdir" \ + "$container" \ + dpkg-buildpackage -S -us -uc