Skip to content

Commit 4ec1ab8

Browse files
authored
Merge pull request #103 from linuxserver/universal-docker-gha-ghcr
Switch to GHA, add GHCR
2 parents 7e3c62d + 783f7a9 commit 4ec1ab8

File tree

3 files changed

+85
-50
lines changed

3 files changed

+85
-50
lines changed

.github/workflows/BuildImage.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build Image
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
ENDPOINT: "linuxserver/mods" #don't modify
7+
BASEIMAGE: "universal" #replace
8+
MODNAME: "docker" #replace
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/[email protected]
15+
16+
- name: Build image
17+
run: |
18+
# Set version
19+
if [ -z ${COMPOSE_TAG+x} ]; then COMPOSE_TAG=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-docker-compose/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]'); fi
20+
if [ -z ${COMPOSE_ALPINE_TAG+x} ]; then COMPOSE_ALPINE_TAG=$(curl -sX GET "https://api.github.com/repos/linuxserver/docker-docker-compose/releases" | jq -r 'first(.[] | select(.prerelease==true)) | .tag_name'); fi
21+
COMPOSE_VERSION=$(echo "$COMPOSE_TAG" | sed 's|-ls.*||g')
22+
echo "COMPOSE_VERSION=${COMPOSE_VERSION}" >> $GITHUB_ENV
23+
COMPOSE_ALPINE_VERSION="$(echo ${COMPOSE_ALPINE_TAG} | sed 's|-ls.*||g' | sed 's|alpine-||g')"
24+
if [ "$COMPOSE_VERSION" != "$COMPOSE_ALPINE_VERSION" ]; then echo "ubuntu and alpine versions are different; exiting!" && exit 1; else echo "ubuntu and alpine versions are the same, continuing with build"; fi
25+
# Build image
26+
docker build --no-cache --build-arg COMPOSE_TAG=${COMPOSE_TAG} --build-arg COMPOSE_ALPINE_TAG=${COMPOSE_ALPINE_TAG} -t ${{ github.sha }} .
27+
28+
- name: Tag image
29+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
30+
run: |
31+
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}
32+
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}
33+
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}-${{ github.sha }}
34+
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
35+
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}
36+
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}
37+
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}-${{ github.sha }}
38+
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
39+
40+
- name: Credential check
41+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
42+
run: |
43+
echo "CR_USER=${{ secrets.CR_USER }}" >> $GITHUB_ENV
44+
echo "CR_PAT=${{ secrets.CR_PAT }}" >> $GITHUB_ENV
45+
echo "DOCKERUSER=${{ secrets.DOCKERUSER }}" >> $GITHUB_ENV
46+
echo "DOCKERPASS=${{ secrets.DOCKERPASS }}" >> $GITHUB_ENV
47+
if [[ "${{ secrets.CR_USER }}" == "" && "${{ secrets.CR_PAT }}" == "" && "${{ secrets.DOCKERUSER }}" == "" && "${{ secrets.DOCKERPASS }}" == "" ]]; then
48+
echo "::error::Push credential secrets missing."
49+
echo "::error::You must set either CR_USER & CR_PAT or DOCKERUSER & DOCKERPASS as secrets in your repo settings."
50+
echo "::error::See https://github.com/linuxserver/docker-mods/blob/master/README.md for more information/instructions."
51+
exit 1
52+
fi
53+
54+
- name: Login to GitHub Container Registry
55+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }}
56+
run: |
57+
echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
58+
59+
- name: Push tags to GitHub Container Registry
60+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }}
61+
run: |
62+
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}
63+
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}-${{ github.sha }}
64+
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
65+
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}
66+
67+
- name: Login to DockerHub
68+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }}
69+
run: |
70+
echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin
71+
72+
- name: Push tags to DockerHub
73+
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }}
74+
run: |
75+
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}
76+
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.COMPOSE_VERSION }}-${{ github.sha }}
77+
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
78+
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}

.travis.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
ARG COMPOSE_TAG="latest"
22
ARG COMPOSE_ALPINE_TAG="alpine"
33

4-
FROM linuxserver/docker-compose:amd64-${COMPOSE_TAG} as compose-amd64
5-
FROM linuxserver/docker-compose:arm32v7-${COMPOSE_TAG} as compose-arm32
6-
FROM linuxserver/docker-compose:arm64v8-${COMPOSE_TAG} as compose-arm64
7-
FROM linuxserver/docker-compose:amd64-${COMPOSE_ALPINE_TAG} as compose-alpine-amd64
8-
FROM linuxserver/docker-compose:arm32v7-${COMPOSE_ALPINE_TAG} as compose-alpine-arm32
9-
FROM linuxserver/docker-compose:arm64v8-${COMPOSE_ALPINE_TAG} as compose-alpine-arm64
4+
FROM ghcr.io/linuxserver/docker-compose:amd64-${COMPOSE_TAG} as compose-amd64
5+
FROM ghcr.io/linuxserver/docker-compose:arm32v7-${COMPOSE_TAG} as compose-arm32
6+
FROM ghcr.io/linuxserver/docker-compose:arm64v8-${COMPOSE_TAG} as compose-arm64
7+
FROM ghcr.io/linuxserver/docker-compose:amd64-${COMPOSE_ALPINE_TAG} as compose-alpine-amd64
8+
FROM ghcr.io/linuxserver/docker-compose:arm32v7-${COMPOSE_ALPINE_TAG} as compose-alpine-arm32
9+
FROM ghcr.io/linuxserver/docker-compose:arm64v8-${COMPOSE_ALPINE_TAG} as compose-alpine-arm64
1010

11-
FROM lsiobase/alpine:3.12 as buildstage
11+
FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage
1212

1313
COPY --from=compose-amd64 /usr/local/bin/docker-compose /root-layer/docker-compose-ubuntu/docker-compose_x86_64
1414
COPY --from=compose-amd64 /usr/local/bin/docker /root-layer/docker-compose-ubuntu/docker_x86_64

0 commit comments

Comments
 (0)