Merge pull request #88 from linuxserver/template-gha

Replace Travis with GHA
This commit is contained in:
aptalca 2020-10-25 20:38:57 -04:00 committed by GitHub
commit 3484da2827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 36 deletions

30
.github/workflows/BuildImage.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: Build Image
on: [push, pull_request, workflow_dispatch]
jobs:
build:
env:
DOCKERHUB: "linuxserver/mods" #don't modify
BASEIMAGE: "baseimagename" #replace
MODNAME: "modname" #replace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.3
- name: Build image
id: build
run: |
docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} .
- name: Push image
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
run: |
# Tag image
docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
# Login to DockerHub
echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin
# Push all of the tags
docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}

View File

@ -1,35 +0,0 @@
os: linux
language: shell
branches:
only:
- <baseimagename>-<modname> #replace variables, omit brackets
services:
- docker
env:
global:
- DOCKERHUB="linuxserver/mods" #don't modify
- BASEIMAGE="baseimagename" #replace
- MODNAME="modname" #replace
jobs:
include:
- stage: PR-BuildImage
if: (type IN (pull_request))
script:
# Build image
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
- stage: BuildImage
if: (NOT (type IN (pull_request)))
script:
# Build image
- docker build --no-cache -t ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} .
- docker tag ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT} ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}
# Login to DockerHub
- echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin
# Push all of the tags
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}-${TRAVIS_COMMIT}
- docker push ${DOCKERHUB}:${BASEIMAGE}-${MODNAME}

View File

@ -12,6 +12,6 @@ If adding multiple mods, enter them in an array separated by `|`, such as `DOCKE
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
* Inspect the `root` folder contents. Edit, add and remove as necessary.
* Edit this readme with pertinent info, delete these instructions.
* Finally edit the `travis.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
* Submit PR against the branch created by the team.