Merge branch 'master' of github.com:digininja/DVWA #26
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: | |
workflow_dispatch: | |
push: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name : Build and push DVWA image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/dvwa | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
[ "$VERSION" == "master" ] && VERSION=latest | |
COMMIT=$(echo "${{ github.sha }}" | cut -c 1-7) | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
echo COMMIT=$COMMIT | |
docker image build --tag dvwa . | |
docker image tag dvwa $IMAGE_ID:$VERSION | |
docker image tag dvwa $IMAGE_ID:$COMMIT | |
docker image push $IMAGE_ID:$VERSION | |
docker image push $IMAGE_ID:$COMMIT |