diff --git a/.github/workflows/chisholm-ray_c05-actions02.yml b/.github/workflows/chisholm-ray_c05-actions02.yml new file mode 100644 index 0000000..22d97dd --- /dev/null +++ b/.github/workflows/chisholm-ray_c05-actions02.yml @@ -0,0 +1,43 @@ +name: 3M workflow with comment on PR + +on: + pull_request: + paths: + - 'chisholm-ray/actions02/**' + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: chisholm-ray/actions02/ + + steps: + - uses: actions/checkout@v2 + + - name: set variables + run: | + echo ${{ github.sha }} | head -c 7 > TAG_SHA + echo "IMAGEFULLNAME=${{ secrets.CCR_DOCKERU }}/actions02:$(cat TAG_SHA)" >> $GITHUB_ENV + + - name: docker login + env: + CCR_DOCKERU: ${{ secrets.CCR_DOCKERU }} + CCR_DOCKERP: ${{ secrets.CCR_DOCKERP }} + run: | + make login + + - name: build image + run: make build + + - name: push image + run: make push + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + + with: + message: 'Image name ${{ env.IMAGEFULLNAME}} has been pushed to dockerhub' + GITHUB_TOKEN: ${{ secrets.CCR_GITHUB_TOKEN}} + \ No newline at end of file diff --git a/chisholm-ray/actions02/Dockerfile b/chisholm-ray/actions02/Dockerfile new file mode 100644 index 0000000..924d736 --- /dev/null +++ b/chisholm-ray/actions02/Dockerfile @@ -0,0 +1,2 @@ + FROM httpd:2.4.51 + RUN echo "This is my GH actions exercise v2" > /usr/local/apache2/htdocs/index.html \ No newline at end of file diff --git a/chisholm-ray/actions02/Makefile b/chisholm-ray/actions02/Makefile new file mode 100644 index 0000000..b0a174c --- /dev/null +++ b/chisholm-ray/actions02/Makefile @@ -0,0 +1,16 @@ +#vars + + +.PHONY: build push login + +build: + @echo "Building image with tag ${IMAGEFULLNAME}" + @docker build -t ${IMAGEFULLNAME} -f ./Dockerfile . + +push: + @echo "Pushing image with tag ${IMAGEFULLNAME} to DockerHub" + @docker image push ${IMAGEFULLNAME} + +login: + @echo "Logging into DockerHub with provided credentials" + @printf ${CCR_DOCKERP} | docker login -u ${CCR_DOCKERU} --password-stdin \ No newline at end of file