|
1 | 1 | 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 |
3 | 5 | on: |
4 | 6 | push: |
5 | 7 | branches: |
6 | 8 | - 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) }} |
7 | 24 |
|
8 | 25 | jobs: |
9 | | - build: |
| 26 | + docker: |
10 | 27 | runs-on: ubuntu-latest |
11 | | - environment: deploy |
12 | 28 | 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