This commit is contained in:
Dawid Dziurla 2020-03-25 23:13:26 +01:00
parent c68af108d8
commit d3ce6af944
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B
7 changed files with 90 additions and 23 deletions

16
.github/workflows/test.yml vendored Normal file
View file

@ -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

View file

@ -1,7 +1,5 @@
FROM alpine:3.10 FROM docker
COPY LICENSE README.md / COPY main.sh /
COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/main.sh"]
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -1,7 +1,7 @@
The MIT License (MIT) 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -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
```

View file

@ -1,12 +1,15 @@
name: 'Container Action Template' name: Build Debian package
description: 'Get started with Container actions' description: Build Debian package from source for selected target release
author: 'GitHub' branding:
color: red
icon: package
inputs: inputs:
myInput: directory:
description: 'Input to use' description: Directory where Debianized sources live (defaults to current)
default: 'world' required: false
os:
description: '"ubuntu" or "debian" (defaults to "debian")'
required: false
runs: runs:
using: 'docker' using: docker
image: 'Dockerfile' image: Dockerfile
args:
- ${{ inputs.myInput }}

View file

@ -1,3 +0,0 @@
#!/bin/sh -l
echo "hello $1"

45
main.sh Executable file
View file

@ -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