From afcc5a19aaa585681803520d850bce35473fc52b Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 24 Oct 2020 13:12:50 -0500 Subject: [PATCH] Replace Travis with GHA --- .github/workflows/BuildImage.yml | 30 +++++++++++++++++++++++++++ .travis.yml | 35 -------------------------------- README.md | 2 +- 3 files changed, 31 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/BuildImage.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml new file mode 100644 index 00000000..7758aa86 --- /dev/null +++ b/.github/workflows/BuildImage.yml @@ -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} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e6e5b1fb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -os: linux - -language: shell - -branches: - only: - - - #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} \ No newline at end of file diff --git a/README.md b/README.md index 62f203fa..5636dec3 100644 --- a/README.md +++ b/README.md @@ -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 `-`. 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.