Last active
September 16, 2023 19:47
-
-
Save mitchallen/48a370c315de03877edfee85e3e08f96 to your computer and use it in GitHub Desktop.
Example GitHub Action workflow to publish a docker container image
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: publish | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
publish-docker-image: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the Docker image | |
run: | | |
tag=${GITHUB_REF#refs/tags/} | |
tag=${tag:1} | |
image=ghcr.io/${GITHUB_REPOSITORY} | |
docker build . -t ${image}:${tag} -t ${image}:latest | |
docker push ${image} --all-tags | |
Author
mitchallen
commented
Sep 16, 2023
- pinned runs-on to a specific version
- added a timeout
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment