-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Starfly-13/build-push-to-registry
Add CI workflow for building and pushing Docker images to container registry
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Publish to Vultr | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
docker: | ||
# skip this workflow if the commit message contains [ci skip] | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
# generate the images and tags we'll publish to the registry | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
sjc.vultrcr.com/starfly13/starfly13 | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=raw,value={{date 'YYYYMMDDHHmmss'}} | ||
type=sha | ||
# check out the code from the repository | ||
- name: Checkout Project | ||
uses: actions/checkout@v4 | ||
|
||
# set up the build | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# log in to the registry | ||
- name: Login to Vultr Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: sjc.vultrcr.com | ||
username: ${{ secrets.VULTR_USERNAME }} | ||
password: ${{ secrets.VULTR_APIKEY }} | ||
|
||
# build and push to the registry | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |