Switch from Travis CI to GitHub actions #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, test and push image | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build-test-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Expose GitHub Runtime | |
uses: crazy-max/ghaction-github-runtime@v3 | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build image and run tests | |
run: | | |
docker buildx build \ | |
--output=type=docker \ | |
--cache-to type=gha,mode=max \ | |
--cache-from type=gha \ | |
--load \ | |
--progress=plain \ | |
--iidfile=iid \ | |
. | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Tag and push image | |
run: | | |
docker tag $(<iid) rootmos/silly-joy:$GITHUB_SHA | |
docker push rootmos/silly-joy:$GITHUB_SHA | |
- name: Mark as latest image | |
if: github.ref_name == 'master' | |
run: | | |
docker tag $(<iid) rootmos/silly-joy:latest | |
docker push rootmos/silly-joy:latest |