Skip to content

add: github actions

add: github actions #1

Workflow file for this run

name: Docker build
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Pull and retag old image
run: |
NEW_DATE=$(date +%d%m%Y%H%M)
docker pull ${{ secrets.DOCKER_USERNAME }}/wyrstream_app:latest
docker tag ${{ secrets.DOCKER_USERNAME }}/wyrstream_app:latest ${{ secrets.DOCKER_USERNAME }}/wyrstream_app:$NEW_DATE
docker push ${{ secrets.DOCKER_USERNAME }}/wyrstream_app:$NEW_DATE
echo "Pushed image $(${{ secrets.DOCKER_USERNAME }}/wyrstream_app:$NEW_DATE)"
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
- name: Cache Docker Image Layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and Push Docker image
uses: docker/build-push-action@v2
id: docker_build
with:
context: ./
file: ./Dockerfile
build-args: |
BASE_URL=${{ secrets.BASE_URL }}
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/wyrstream_app:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Verify
run: echo ${{ steps.docker_build.outputs.digest }}