Skip to content

Commit 3e73696

Browse files
Converto to GitHub actions (#364)
1 parent ac6d647 commit 3e73696

File tree

5 files changed

+104
-55
lines changed

5 files changed

+104
-55
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Docker build & push
2+
3+
on:
4+
push:
5+
branches: master
6+
7+
jobs:
8+
docker-description:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: description
14+
run: |
15+
DOCKERHUB_USERNAME=$DOCKER_USERNAME DOCKERHUB_PASSWORD=$DOCKER_PASSWORD DOCKERHUB_REPOSITORY='factoriotools/factorio' README_FILEPATH='./README.md' ./update-dockerhub-description.sh

.github/workflows/docker.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Docker build & push
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: master
7+
8+
jobs:
9+
old-version:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
version: [ 0.18, 0.17, 0.16, 0.15, 0.14 ]
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: build
18+
env:
19+
VERSION_SHORT: ${{ matrix.version }}
20+
run: |
21+
./build.sh ${{ matrix.version }}
22+
23+
stable:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
- name: build
29+
env:
30+
EXTRA_TAG: stable
31+
VERSION_SHORT: 1.0
32+
run: |
33+
./build.sh $VERSION_SHORT
34+
35+
experimental:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
- name: build
41+
env:
42+
EXTRA_TAG: latest
43+
VERSION_SHORT: 1.1
44+
run: |
45+
./build.sh $VERSION_SHORT

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Linter'
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: master
7+
8+
jobs:
9+
shellcheck:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: shellcheck
14+
uses: reviewdog/action-shellcheck@v1
15+
with:
16+
github_token: ${{ secrets.github_token }}
17+
reporter: github-pr-review
18+
19+
hadolint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: hadolint
24+
uses: reviewdog/action-hadolint@v1
25+
with:
26+
github_token: ${{ secrets.github_token }}
27+
reporter: github-pr-review

.travis.yml

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

build.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ cd "$VERSION_SHORT" || exit 1
1616
VERSION=$(grep -oP '[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1)
1717
DOCKER_REPO=factoriotools/factorio
1818

19-
if [[ ${TRAVIS_PULL_REQUEST:-} == true ]]; then
20-
TAGS="$DOCKER_REPO:$TRAVIS_PULL_REQUEST_SLUG"
19+
BRANCH=${GITHUB_REF#refs/heads/}
20+
21+
if [[ -n ${GITHUB_BASE_REF:-} ]]; then
22+
TAGS="$DOCKER_REPO:$GITHUB_BASE_REF"
2123
else
2224
if [[ -n ${CI:-} ]]; then
2325
# we are either on master or on a tag build
24-
if [[ ${TRAVIS_BRANCH:-} == master || ${TRAVIS_BRANCH:-} == "$VERSION" ]]; then
26+
if [[ ${BRANCH:-} == master || ${BRANCH:-} == "$VERSION" ]]; then
2527
TAGS="-t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
2628
# we are on an incremental build of a tag
27-
elif [[ $VERSION == "${TRAVIS_BRANCH%-*}" ]]; then
28-
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
29+
elif [[ $VERSION == "${BRANCH%-*}" ]]; then
30+
TAGS="-t $DOCKER_REPO:$BRANCH -t $DOCKER_REPO:$VERSION -t $DOCKER_REPO:$VERSION_SHORT"
2931
# we build a other branch than master and exclude dependabot branches from tags cause the / is not supported by docker
30-
elif [[ -n ${TRAVIS_BRANCH:-} && ! $TRAVIS_BRANCH =~ "/" ]]; then
31-
TAGS="-t $DOCKER_REPO:$TRAVIS_BRANCH"
32+
elif [[ -n ${BRANCH:-} && ! $BRANCH =~ "/" ]]; then
33+
TAGS="-t $DOCKER_REPO:$BRANCH"
3234
fi
3335
else
3436
# we are not in CI and tag version and version short
@@ -58,13 +60,13 @@ docker images
5860

5961
# remove -1 from incremental tag
6062
# eg before: 0.18.24-1, after 0.18.24
61-
if [[ ${TRAVIS_BRANCH:-} ]]; then
62-
TRAVIS_BRANCH_VERSION=${TRAVIS_BRANCH%-*}
63+
if [[ ${BRANCH:-} ]]; then
64+
BRANCH_VERSION=${BRANCH%-*}
6365
fi
6466

6567
# only push when:
6668
# or we build a tag and we don't build a PR
67-
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_PULL_REQUEST_BRANCH:-} == "" ]] ||
69+
if [[ $VERSION == "${BRANCH_VERSION:-}" && ${GITHUB_BASE_REF:-} == "" ]] ||
6870
# or we are not in CI
6971
[[ -z ${CI:-} ]]; then
7072

@@ -73,18 +75,18 @@ if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_PULL_REQUEST_BRANCH:-
7375
fi
7476

7577
# push a tag on a branch other than master except dependabot branches cause docker does not support /
76-
if [[ -n ${TRAVIS_BRANCH:-} && $VERSION != "${TRAVIS_BRANCH_VERSION:-}" && ${TRAVIS_BRANCH:-} != "master" && ! ${TRAVIS_BRANCH:-} =~ "/" ]]; then
77-
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
78+
if [[ -n ${BRANCH:-} && $VERSION != "${BRANCH_VERSION:-}" && ${BRANCH:-} != "master" && ! ${BRANCH:-} =~ "/" ]]; then
79+
docker push "$DOCKER_REPO:$BRANCH"
7880
fi
7981

8082
# push an incremental tag
8183
# eg 0.18.24-1
82-
if [[ $VERSION == "${TRAVIS_BRANCH_VERSION:-}" ]]; then
83-
docker push "$DOCKER_REPO:$TRAVIS_BRANCH"
84+
if [[ $VERSION == "${BRANCH_VERSION:-}" ]]; then
85+
docker push "$DOCKER_REPO:$BRANCH"
8486
fi
8587

8688
# only push on tags or when manually running the script
87-
if [[ -n ${TRAVIS_TAG:-} || -z ${CI:-} ]]; then
89+
if [[ -n ${GITHUB_BASE_REF:-} || -z ${CI:-} ]]; then
8890
docker push "$DOCKER_REPO:$VERSION"
8991
docker push "$DOCKER_REPO:$VERSION_SHORT"
9092
fi

0 commit comments

Comments
 (0)