mirror of
https://github.com/pushbits/server.git
synced 2025-05-01 11:17:11 +02:00
Use dedicated workflow for publishing
This commit is contained in:
parent
28dd32f248
commit
c2425b239c
2 changed files with 33 additions and 20 deletions
22
.github/workflows/main.yml
vendored
22
.github/workflows/main.yml
vendored
|
@ -1,8 +1,8 @@
|
|||
name: Main
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test_build_publish:
|
||||
name: Test, build, and publish
|
||||
test_build:
|
||||
name: Test and build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
@ -17,21 +17,3 @@ jobs:
|
|||
run: make test
|
||||
- name: Build image
|
||||
run: make build_image
|
||||
- name: Get Branch # Needed to evaluate env.BRANCH.
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' }} # Otherwise will fail on pull requests.
|
||||
run: |
|
||||
echo "Getting branch name..."
|
||||
raw=$(git branch -r --contains ${{ github.ref }})
|
||||
echo "raw: $raw"
|
||||
branch=${raw##*/}
|
||||
echo "branch: $branch"
|
||||
echo "BRANCH=$branch" >> $GITHUB_ENV
|
||||
- name: Login to Docker Hub
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' && env.BRANCH == 'master' }} # Only login for tagged commits pushed to master.
|
||||
uses: docker/login-action@v1
|
||||
with: # Secrets are not exposed to pull request contexts.
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Publish image
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' && env.BRANCH == 'master' }} # Only publish for tagged commits pushed to master.
|
||||
run: make push_image
|
||||
|
|
31
.github/workflows/publish.yml
vendored
Normal file
31
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
name: Publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
test_build_publish:
|
||||
name: Test, build, and publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Export GOBIN
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
- name: Install dependencies
|
||||
run: make setup
|
||||
- name: Run tests
|
||||
run: make test
|
||||
- name: Build image
|
||||
run: make build_image
|
||||
- name: Login to Docker Hub
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # Only login for tagged commits.
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Publish image
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} # Only publish for tagged commits.
|
||||
run: make push_image
|
Loading…
Add table
Reference in a new issue