Skip to content

Commit 165e70e

Browse files
committed
Update CI workflow to build and push Docker container
1 parent 994a228 commit 165e70e

1 file changed

Lines changed: 41 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
name: CI
2-
run-name: Publicación de la pagina web
2+
run-name: Publicación de la pagina web como un contenedor Docker
3+
4+
# Trigger the workflow on push or merge
35
on:
46
push:
57
branches:
68
- master
9+
pull_request_target:
10+
types: closed
11+
branches:
12+
- master
13+
14+
concurrency:
15+
group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}'
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
env:
23+
REPO: ${{ toLower(github.repository) }}
724

825
jobs:
9-
build:
26+
docker:
1027
runs-on: ubuntu-latest
11-
environment: deploy
1228
steps:
13-
- name: Checkout the current branch
14-
uses: actions/checkout@v3
15-
16-
- name: Initialize the ssh-agent
17-
uses: webfactory/ssh-agent@v0.4.1
18-
with:
19-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
20-
21-
- name: Create the docker image
22-
run: make init
23-
24-
- name: Build the website
25-
run: make build
26-
27-
- name: Scan the host key
28-
run: mkdir -p ~/.ssh/ && ssh-keyscan -p $DEPLOY_PORT -H $DEPLOY_SERVER >> ~/.ssh/known_hosts
29-
env:
30-
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
31-
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
32-
33-
- name: Deploy the website
34-
run: >-
35-
rsync -avx -e "ssh -p $DEPLOY_PORT" --delete --exclude '.ssh' public/ $DEPLOY_USERNAME@$DEPLOY_SERVER:$DEPLOY_PATH
36-
env:
37-
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
38-
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
39-
DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }}
40-
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Log in to ghcr
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v5
46+
with:
47+
push: true
48+
tags: ghcr.io/${{ env.REPO }}:${{ github.ref_name }}, ghcr.io/${{ env.REPO }}:${{ github.sha }}
49+
platforms: linux/amd64
50+

0 commit comments

Comments
 (0)