diff --git a/.github/workflows/test.yml b/.github/workflows/build+test.yml similarity index 66% rename from .github/workflows/test.yml rename to .github/workflows/build+test.yml index 9e33d16..44a933a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/build+test.yml @@ -1,5 +1,13 @@ -name: Tests -on: [push] +name: Build/Test + +on: + push: + branches: + - v3 + - devel + - master + tags: + - 'v*.*.*' jobs: test-mothd: @@ -9,20 +17,36 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.13 + go-version: 1.13 + - name: Retrieve code - uses: actions/checkout@v1 + uses: actions/checkout@v2 + - name: Test run: go test ./... publish: - name: Publish latest build + name: Publish container images runs-on: ubuntu-latest steps: - name: Retrieve code - uses: actions/checkout@v1 + uses: actions/checkout@v2 + + - name: Get current branch + id: vars + run: | + case $GITHUB_REF in + refs/tags/*) + TAGS=latest,${GITHUB_REF#refs/tags/} + ;; + refs/heads/master) + TAGS=latest + ;; + esac + echo "::set-output name=tags::$TAGS" - name: Login to GitHub Packages Docker Registry + if: steps.vars.tags != '' uses: docker/login-action@v1 with: registry: docker.pkg.github.com @@ -30,6 +54,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Login to DockerHub + if: steps.vars.tags != '' uses: docker/login-action@v1 with: username: neale diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 5f0fcc3..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Publish -on: - push: - tags: - - 'v*' # Only versioned tags - -jobs: - publish: - name: Publish Container Image - runs-on: ubuntu-latest - steps: - - name: Retrieve code - uses: actions/checkout@v1 - - - name: Push moth to GitHub Packages - uses: docker/build-push-action@v2 - with: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - target: moth - file: build/package/Containerfile - registry: docker.pkg.github.com - repository: dirtbags/moth/moth - tag_with_ref: true - - - name: Push moth-devel to GitHub Packages - uses: docker/build-push-action@v2 - with: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - target: moth-devel - file: build/package/Containerfile - registry: docker.pkg.github.com - repository: dirtbags/moth/moth-devel - tag_with_ref: true - - - name: Push moth to Docker Hub - uses: docker/build-push-action@v2 - with: - username: neale - password: ${{ secrets.DOCKER_TOKEN }} - target: moth - file: build/packages/Containerfile - repository: dirtbags/moth - tag_with_ref: true - - - name: Push moth-devel to Docker Hub - uses: docker/build-push-action@v2 - with: - username: neale - password: ${{ secrets.DOCKER_TOKEN }} - target: moth-devel - file: build/packages/Containerfile - repository: dirtbags/moth-devel - tag_with_ref: true