Skip to content

remove deprecated steps and update pipeline versions #99

remove deprecated steps and update pipeline versions

remove deprecated steps and update pipeline versions #99

Workflow file for this run

name: CI
on:
pull_request:
jobs:
Build-and-Push-Image:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Build and Push Image to Image registry
env:
REGISTRY: docker.io
defaults:
run:
shell: bash
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Build Code
run: |
go mod download
go build -v .
- name: Initialize Pipeline
uses: mshick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: "@${{ github.actor }} GitHub Actions has started building this code. Check status at 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'"
message-id: ${{ github.run_id }}-${{ github.run_attempt }}
- name: Generate Vars
id: generate_vars
run: |
# Just Tag
IMAGE_TAG=pr-${{ github.event.pull_request.number }}-$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)
# Just Image name
IMAGE_NAME=${{ github.repository }}
#Image ID= Name + Tag
IMAGE_ID=$IMAGE_NAME:$IMAGE_TAG
IMAGE_REPO=$REGISTRY/$IMAGE_ID
echo "Image: $IMAGE_REPO"
echo "::set-output name=image::$IMAGE_REPO"
echo "::set-output name=image_name::$IMAGE_NAME"
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Echo Output
run: |
echo "Image from Output: ${{ steps.generate_vars.outputs.image }}"
echo "Repo from Output: ${{ steps.generate_vars.outputs.image_name }}"
- name: Build and Push Docker Image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
pull: true
push: true
tags: ${{ steps.generate_vars.outputs.image }}
- name: Comment on PR
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: '@${{ github.actor }} Image is available for testing. `docker pull ${{ steps.generate_vars.outputs.image }}`'
allow-repeats: false
- name: Notify Failure
if: failure()
uses: mshick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: '@${{ github.actor }} The pipeline failed! You better fix it before anyone else finds out! [Build](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}/checks) has Failed!'
allow-repeats: false
- name: Notify Slack
uses: 8398a7/action-slack@v3
if: always()
with:
status: ${{ job.status }}
fields: repo,author,action,eventName,ref,workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}