Skip to content

Commit

Permalink
feat: publish latest, alpha and beta tags on docker
Browse files Browse the repository at this point in the history
Publish latest, alpha and beta tags on docker
  • Loading branch information
ryshu committed Aug 27, 2022
1 parent e1f48fb commit ba0d14d
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions .github/workflows/semver_build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,64 @@ name: Semver, Build, Publish

on:
push:
branches: [ main, alpha, beta ]
branches: [main, alpha, beta]

jobs:
semver:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Semantic Release - prepare
run: |
- name: Checkout
uses: actions/checkout@v3
- name: Semantic Release - prepare
run: |
cat <<EOF > package.json
{
"name": "semver",
"private": true
}
EOF
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 16
branches: |
[
'main',
{
name: 'alpha',
prerelease: true
},
{
name: 'beta',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: semantic
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 16
branches: |
[
'main',
{
name: 'alpha',
prerelease: true
},
{
name: 'beta',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: semantic
outputs:
version: ${{ steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_channel: ${{ steps.semantic.outputs.new_release_channel }}

build_and_publish:
runs-on: ubuntu-latest
needs: [ semver ]
needs: [semver]
if: needs.semver.outputs.new_release_published == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: docker build . -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ needs.semver.outputs.version }}
- name: Tag using channel
run: |
CHANNEL=${{ needs.semver.outputs.new_release_channel }}
docker build . -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${CHANNEL:-'latest'}
- name: Login to Docker Hub
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ needs.semver.outputs.version }}
- name: Push image on channel tag
run: |
CHANNEL=${{ needs.semver.outputs.new_release_channel }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${CHANNEL:-'latest'}

0 comments on commit ba0d14d

Please sign in to comment.