Create docker-image.yml #1
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: Docker Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Change directory to app | |
run: cd app | |
- name: Determine version from codebase | |
run: | | |
# Example: Extract version from package.json | |
VERSION=$(jq -r '.version' package.json) | |
echo "::set-output name=version::$VERSION" | |
- name: Log in to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Build Docker image | |
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/onebox:${{ steps.determine_version.outputs.version }} . | |
- name: Push Docker image to Docker Hub | |
run: docker push ${{ secrets.DOCKER_USERNAME }}/onebox:${{ steps.determine_version.outputs.version }} | |