-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Github Actions Workflow docker-image * Fix env * Fix checkout * Fix invalid imageTag * Fix default version 6.0.8 instead of 6.8.0 * Add Labels
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
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,56 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: ["main", "dev*"] | ||
tags: ["*.*.*"] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
image-tag: [alpine3.16, bullseye-slim, focal, jammy] | ||
name: ${{ matrix.image-tag }} | ||
runs-on: ubuntu-latest | ||
env: | ||
ASPNET_VERSION: "6.0.8" | ||
SKIP_DOCKER: "false" | ||
steps: | ||
- name: Set version from TAG | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
run: | | ||
echo "ASPNET_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
echo "Update ASPNET_VERSION to ${GITHUB_REF#refs/*/}" | ||
- name: Skip docker build | ||
if: ${{ matrix.image-tag == 'focal' && startsWith(env.ASPNET_VERSION, '7.0') }} | ||
run: echo "SKIP_DOCKER=true" >> $GITHUB_ENV | ||
- uses: actions/checkout@v2 | ||
if: ${{ env.SKIP_DOCKER != 'true' }} | ||
- name: Docker meta | ||
id: meta | ||
if: ${{ env.SKIP_DOCKER != 'true' }} | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: netlah/aspnet-webssh | ||
tags: | | ||
type=ref,event=branch,priority=600,prefix=,suffix= | ||
type=sha,enable=true,priority=500,prefix=sha-,suffix=,format=short | ||
- name: Login to Docker Hub | ||
if: ${{ success() && env.SKIP_DOCKER != 'true' && github.event_name != 'pull_request' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
- name: Build and push on tag | ||
if: ${{ success() && env.SKIP_DOCKER != 'true' && github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }} | ||
env: | ||
IMAGE_TAG: ${{ env.ASPNET_VERSION }}-${{ matrix.image-tag }} | ||
shell: pwsh | ||
run: ./docker-build.ps1 -imageTag ${{ env.IMAGE_TAG }} -dockerRepository netlah/aspnet-webssh,${{ secrets.DOCKER_HUB_REPOS }} -Labels "${{ steps.meta.outputs.labels }}" -Verbose | ||
- name: Build and push on branch | ||
if: ${{ success() && env.SKIP_DOCKER != 'true' && github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/tags/') }} | ||
env: | ||
IMAGE_TAG: ${{ env.ASPNET_VERSION }}-${{ matrix.image-tag }} | ||
shell: pwsh | ||
run: ./docker-build.ps1 -imageTag ${{ env.IMAGE_TAG }} -dockerRepository ${{ secrets.DOCKER_HUB_REPOS }} -Labels "${{ steps.meta.outputs.labels }}" -Verbose |
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
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