ci: address upload artifact overwrite #4
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: [ main ] | |
workflow_dispatch: | |
inputs: | |
docker_registry: | |
description: 'Registry URL' | |
required: true | |
default: 'docker.io/username' | |
image_name: | |
description: 'Name you wish to use on the docker image (ex. myapp). This will be tagged with :latest, and the git sha' | |
required: true | |
default: 'app' | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.0.0 | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:latest --tag ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:${{ github.sha }} | |
- name: Docker Login | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ github.event.inputs.docker_registry }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
logout: true | |
- name: Push the Docker image to ${{ github.event.inputs.docker_registry }} | |
run: docker push ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }} | |
- name: Push the Docker image to ${{ github.event.inputs.docker_registry }} | |
run: docker push ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:${{ github.sha }} |