Skip to content

Commit

Permalink
fix cicd action
Browse files Browse the repository at this point in the history
  • Loading branch information
gilmaimon committed Jul 27, 2024
1 parent 241c561 commit 20eaa72
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ on:
push:
branches:
- '**' # Triggers on push to any branch
pull_request:
branches:
- master # Triggers on PR to master branch
workflow_dispatch: # Manually trigger the workflow

jobs:
build:
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest

steps:
Expand All @@ -21,19 +17,39 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker image
run: docker build -t server .
- name: Build and export
uses: docker/build-push-action@v6
with:
tags: server:latest
outputs: type=docker,dest=/tmp/myimage.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: myimage
path: /tmp/myimage.tar

deploy:
needs: build # Ensure deploy job waits for build job
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}


- name: Download artifact
uses: actions/download-artifact@v4
with:
name: myimage
path: /tmp

- name: Load image
run: |
docker load --input /tmp/myimage.tar
docker image ls -a
- name: Push Docker image
run: docker push server:latest
run: docker tag server:latest tapud/ardu-badge:latest && docker push tapud/ardu-badge:latest

0 comments on commit 20eaa72

Please sign in to comment.